Azure-Samples/service-fabric-dotnet-getting-started

System.Net.WebException: Unable to connect to the remote server

snpdev opened this issue · 5 comments

Please assist with this problem I encounter:

On the page http://localhost:8081/Home/Stateful, when I enter a key value paid and click the Add button, a "404 Not Found" is displayed (Figure 1).

The debug output is as follows:

Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker: Information: Executing action method WebService.Controllers.StatefulBackendServiceController.PutAsync (WebService) with arguments ([B, Bing]) - ModelState is Valid
...
Exception thrown: 'System.Net.Http.HttpRequestException' in mscorlib.dll
Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware: Error: An unhandled exception has occurred: An error occurred while sending the request.

System.Net.Http.HttpRequestException: An error occurred while sending the request. ---> 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 127.0.0.1:19081
   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)
   --- End of inner exception stack trace ---
   at System.Net.HttpWebRequest.EndGetRequestStream(IAsyncResult asyncResult, TransportContext& context)
   at System.Net.Http.HttpClientHandler.GetRequestStreamCallback(IAsyncResult ar)
   --- End of inner exception stack trace ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
   at WebService.Controllers.StatefulBackendServiceController.<PutAsync>d__6.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.<InvokeActionFilterAsync>d__28.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.<InvokeAsync>d__18.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.AspNetCore.Builder.RouterMiddleware.<Invoke>d__4.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware.<Invoke>d__6.MoveNext()

Figure 1
image

The same error on GetAll clicks as well. It tries to perform GET Operation at http://localhost:19081/GettingStartedApplication/StatefulBackendService/api/values?PartitionKind=Int64Range&PartitionKey=-9223372036854775808
which returns "Not Response!"

I'm not sure where that port "19081" comes into pictures, where the stateful service is listening on some random port. Needs some clarification here!

It looks like the partition count is 6 for cloud deployment and the key range is all Int64

<UniformInt64Partition PartitionCount="[StatefulBackendService_PartitionCount]" LowKey="-9223372036854775808" HighKey="9223372036854775807" />

Shouldn't the partition number be 26 and the key range from 0 to 25, if the partition scheme is the first capital letter?
(edited: partition number can be scaled)

Hi @snpdev,

Did you ever solve this problem? I'm trying to get an application up and running and the reverse proxy is not working. I'm following the following article...

https://docs.microsoft.com/en-us/azure/service-fabric/service-fabric-quickstart-dotnet

Thanks.

Port 19081 is the default reverse proxy port. You need to deploy the sample to a Azure Service Fabric cluster with the reverse proxy feature enabled. More information on the reverse proxy feature of Azure Service Fabric can be found here.

Thanks. I was trying to get it working in my local development environment using the SDK.

I found online that it doesn't work on Windows 7 unfortunately.