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

Get started with Service Fabric with these simple introductory sample projects.
MIT License
230 stars 329 forks source link

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

Open snpdev opened 7 years ago

snpdev commented 7 years ago

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

GopiMtp commented 7 years ago

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!

jeremymeng commented 7 years ago

It looks like the partition count is 6 for cloud deployment and the key range is all Int64 https://github.com/Azure-Samples/service-fabric-dotnet-getting-started/blob/e5641cba3a284a84c00937ddcbfb4ac4b01463a9/src/GettingStartedApplication/GettingStartedApplication/ApplicationPackageRoot/ApplicationManifest.xml#L66

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)

https://github.com/Azure-Samples/service-fabric-dotnet-getting-started/blob/cf8070ea3a1c5931badf7dc55da064be47e5b38d/src/GettingStartedApplication/WebService/Controllers/StatefulBackendServiceController.cs#L141

darrenprunty commented 7 years ago

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.

shawnweisfeld commented 7 years ago

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.

darrenprunty commented 7 years ago

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.