I have a Windows 2008 Server with IIS 7.5 and one IP. There are two Application under the root, /web and /service. /web is a MVC4 application, and /service is a WCF 4.0 service.
When I consume the service from MVC, I use the following code:
// Create the web request
HttpWebRequest request = WebRequest.Create(TripServiceUrl + id) as HttpWebRequest;
// Get response
using (HttpWebResponse response = request.GetResponse() as HttpWebResponse)
{
// Get the response stream
StreamReader reader = new StreamReader(response.GetResponseStream());
// Console application output
tripJson = reader.ReadToEnd();
}
I get the following SocketException:
[SocketException (0x274c): A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond 10.243.6.43:80]
System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress) +273
System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Exception& exception) +584
However, I can see 10.243.6.43:80 (an internal address) from a browser on the server and successfully call the service. The IP is not publicly accessible.
What configuration should I have to do to make a self referential call like that work?
It's probably a loopback problem (security issue). See http://support.microsoft.com/kb/896861.
To summarize:
In Registry Editor, locate and then click the following registry key:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Lsa
Right-click Lsa, point to New, and then click DWORD Value.
Type DisableLoopbackCheck, and then press ENTER.
Right-click DisableLoopbackCheck, and then click Modify.
In the Value data box, type 1, and then click OK.
Don't follow the step about DisableStrictNameChecking.
You'll also find a lot of reasons not to do this (you are, after all, disabling a security check), followed by a lot of people saying it's the only way to get SharePoint to work properly. In any event, it will help you determine if this is the problem.
Related
Recently we were facing an issue in client place is that we were unable to communicate to web service even we checked that there is no system proxy set in that system, to overcome this we had given a dummy proxy (localhost:port) and its started working well but after some days with dummy proxy it was unable to communicate to service if we remove dummy proxy then it started working well. i am not able to understand what is blocking me to communicate to service. what may be the issue and how can we overcome this problem. This issue is happening only on some system.
Actually it has to go and hit this URL http://********-tech.in:8080/******dp/ClientVersion but suddenly it started hitting this one 125.21.244.38:8080 why i am not able to conclude.
2017-05-05 00:19:44,721 ERROR [Heartbeat Service ] - Exception while sending heartbeat to manager.
System.Net.WebException: Unable to connect to the remote server ---> System.Net.Sockets.SocketException: No connection could be made because the target machine actively refused it 125.21.244.38:8080
at System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress)
at System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Exception& exception)
--- End of inner exception stack trace ---
at System.Net.HttpWebRequest.GetRequestStream(TransportContext& context)
at System.Net.HttpWebRequest.GetRequestStream()
at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters)
at HeartbeatWSImplService.heartbeat(String probeUid, heartbeatRequest heartbeatRequest)
at ProHance.ProbeHeartBeat.HeartBeat.timer_Elapsed(Object sender, ElapsedEventArgs e)
Please read this post here they are telling to set the default proxy for the webservice request, they are trying to the proxy details while connecting to google. If there is no proxy configured you can try the method mentioned there. Set the default proxy.
We deliver on-premise software that is exposed to the cloud using Azure Service bus relay, the basic code we use to expose is as follows (I have removed everything identifiable):
ServiceHost sh = new ServiceHost(typeof(BasicHttpEntityService));
BasicHttpRelayBinding basicHttpRelayBinding = new BasicHttpRelayBinding();
Uri uriEndPointAddress = ServiceBusEnvironment.CreateServiceUri("https", "ourdomain", "test-url-appendage");
m_shRelayServiceHost.AddServiceEndpoint(
typeof(IMyService),
basicHttpRelayBinding,
uriEndPointAddress
).Behaviors.Add(
new TransportClientEndpointBehavior
{
TokenProvider = TokenProvider.CreateSharedSecretTokenProvider(
"MyUser",
"MyPassword")
});
sh.Open();
This works fine at most of our customers, however, one of our customers has a strict firewall policy.
According to the SB guidelines we have found, we asked them to open ports 9351-9354 to ourdomain.servicebus.windows.net. Now we find out that when there is an incoming request, the service connects to both 'ourdomain' (we see this succeeds in Wireshark, and also in the WCF log) AND an unknown (to us) service on 40.112.124.x:9352 (the last octet changes with every request).
I have been able to reproduce the problem in my development environment by disallowing connections to any 40.x.x.x address on any port. This is what happens in the WCF log:
System.Net.Sockets.SocketException (0x80004005): An attempt was made to access a socket in a way forbidden by its access permissions 40.112.124.25:9352
Server stack trace:
at System.Net.Sockets.Socket.EndConnect(IAsyncResult asyncResult)
at Microsoft.ServiceBus.RelayedConnectionSession.ConnectAsyncResult.<GetAsyncSteps>b__4(ConnectAsyncResult thisRef, IAsyncResult r)
at Microsoft.ServiceBus.Messaging.IteratorAsyncResult`1.StepCallback(IAsyncResult result)
Exception rethrown at [0]:
at Microsoft.ServiceBus.Common.AsyncResult.End[TAsyncResult](IAsyncResult result)
at Microsoft.ServiceBus.RelayedConnectionSession.EndConnect(IAsyncResult result)
There is no DNS-request going out during this time, so there is no host name that provides any clues to the function of this outgoing connection.
From my investigation, this appears to be a Microsoft controlled subnet, so I'm fine with the relay service connecting to it, but I would like to know:
Is this additional connection optional?
If not, should we allow the entire subnet?
Could this IP-range change in the future? Is it hardcoded somewhere?
In the end, we requested support from Microsoft.
In short their answers were as follows:
Is this additional connection optional?
No it is not optional. For the relay listener, there is a control channel on port 5671, this connection is always there. Then there is a data channel on portal 9352, this connection established when there is a relay client tries to communicate with the listener.
Could this IP-range change in the future?
Currently, for relay this IP can change, so you need to allow the IP range for the entire datacenter in your region (https://www.microsoft.com/en-us/download/confirmation.aspx?id=41653). The SB product team will be working on to significantly reduce this IP range in the future, to make it much more predictable. There is no exact ETA on this future.
So the good news is they are working on it. The bad news is, that right now, we will need to add a LOT of IP addresses to the white-list to ensure smooth operation.
The WebDriver-based tests for our web application requires multiple browser windows open at once: one opens the consumer-facing portal, the other opens the administrator portal (to ensure changes in one are seen in the other). This is done by creating two seperate WebDriver objects: eg
IWebDriver driver1 = DriverFactory.NewChromeDriver();
IWebDriver driver2 = DriverFactory.NewChromeDriver();
The test can access both WebDrivers as desired. Our tests are specified in SpecFlow and implemented as MSTest cases. The tests are developed in VisualStudio 2013 Premium, and the drivers simply use the local machine's ChromeDriver instance. All well and good.
When a test performs some actions in Driver2 (say, logging in) and then moves back to Driver1, I end up with a SocketException being thrown because localhost actively refused the connection. Windows Firewall has been told to permit the application on all ports, the factory sets up the proxy correctly. The precise stack trace is:
System.Net.Sockets.SocketException: No connection could be made because the target machine actively refused it 127.0.0.1:50467
Result StackTrace:
at System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress)
at System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Exception& exception)
Firefox opens one browser and then gives up. IE can't even FIND the browser when multiple windows are open.
(I never had this problem until I installed the latest update for VS2013....)
Any ideas? Thanks team.
It transpires that Selenium may indeed throw a WebDriver exception if an element is not present in the DOM. In the end, I had to wrap my accessing code within a try-catch: if the WebDriver exception wraps a WebException that wraps a SocketException, and the SocketException's SocketErrorCode is ConnectionRefused, that means the element is indeed absent from the DOM.
I am trying to get an MVC4 WebApi to use the Microsoft.Exchange.WebServices library, but for some reason it is not connecting to the remote server, instead it looks like it's connecting to the loopback address.
The weird thing is that the exact same code works if used in a console application.
I encapsulated the problem in this simple block of code:
Folder exchangeFolder = null;
ExchangeService service = new ExchangeService();
service.Timeout = 600000;
service.Url = new Uri("https://HOSTNAME/exchange.asmx");
service.Credentials = new NetworkCredential("USERNAME", "PASSWORD", "DOMAIN");
FindFoldersResults findFolderResults = service.FindFolders(WellKnownFolderName.MsgFolderRoot, new FolderView(int.MaxValue));
foreach (Folder folder in findFolderResults)
{
if ("inbox".Equals(folder.DisplayName, StringComparison.InvariantCultureIgnoreCase))
{
exchangeFolder = folder;
break;
}
}
int inboxItemCount = exchangeFolder.TotalCount;
The innermost exception gives me the following details:
{"No connection could be made because the target machine actively refused it 127.0.0.1:6699"}
at System.Net.Sockets.Socket.EndConnect(IAsyncResult asyncResult)
at System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Exception& exception)
The code fails with the same exception in both, ASP.NET applications and MVC4 WebApi applications, but works on Console applications.
Is it possible for those types of applications to use the Microsoft.Exchange.WebServices library?
If so, what else needs to be configured to get it working?
you need the reference using Microsoft.Exchange.WebServices.Data;
it can be installed by the nuget package Microsoft exchange webserivices
make sure the dll deploys with your code to the host server
I'm using .Net Web Request to read the html of selected Webpages.
Once in a while I'm getting the following error:
2010-09-05 13:14:51,986 [File_29] ERROR Boxer.Classes.GetLinks [(null)] - HtmlUtils - GetResponse - Url - http://domain.com/index.html
System.Net.WebException: Unable to connect to the remote server ---> System.Net.Sockets.SocketException: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond 69.212.110.118:5068
at System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress)
at System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Int32 timeout, Exception& exception)
--- End of inner exception stack trace ---
at System.Net.HttpWebRequest.GetResponse()
at Boxer.Classes.GetLinks.GetResponse(String url, Int32 timeout, Boolean& timeoutException)
I know for sure that the target URL is available.
Any idea what is the cause of the error?
There could be different reasons for this happening. Maybe the target server is throttling the response because it believes the request comes from a bot. In this case you might consider sending proper HTTP headers (if it works in your browser, try sending the same request headers). Also there could be a proxy in between that you need to configure and use.