jamiewest / signalr_core

ASP.NET Core SignalR Dart Client
https://pub.dev/packages/signalr_core
MIT License
90 stars 62 forks source link

Failed to connect to Signalr Hub #75

Closed RemcoSchrijver closed 2 years ago

RemcoSchrijver commented 2 years ago

I am having trouble connecting to the Signalr hub from my physical android debug device, I get the following error message:

I/flutter (13844): Starting HubConnection. I/flutter (13844): Starting connection with transfer format 'TransferFormat.text'. I/flutter (13844): Sending negotiation request: http://192.168.1.115:5000/updateHub/negotiate. D/libc-netbsd(13844): [getaddrinfo]: hostname = x.x.x.x; servname = x.x.x.x; netid=0; mark=0 D/libc-netbsd(13844): getaddrinfo( app_uid:10145 D/libc-netbsd(13844): getaddrinfo() uid prop: D/libc-netbsd(13844): getaddrinfo() getuid():10145 D/libc-netbsd(13844): [getaddrinfo]: mtk ai_addrlen=0; ai_canonname=(null); ai_flags=1024; ai_family=0 I/flutter (13844): Failed to complete negotiation with the server: SocketException: OS Error: Connection refused, errno = 111, address = 192.168.1.115, port = 46444 I/flutter (13844): Failed to start the connection: SocketException: OS Error: Connection refused, errno = 111, address = 192.168.1.115, port = 46444 I/flutter (13844): HubConnection failed to start successfully because of error '{SocketException: OS Error: Connection refused, errno = 111, address = 192.168.1.115, port = 46444.toString()}'. [log] Error, failed to start listening SocketException: OS Error: Connection refused, errno = 111, address = 192.168.1.115, port = 46444

And it seems to me it connects to the wrong port?

RemcoSchrijver commented 2 years ago

Fixed my own issue, the problem was that the Asp.Net application still used the endpoint of http://localhost:5000 instead of http://192.168.1.115:5000 after changing this endpoint this got fixed.

So I added this to the app settings: "Kestrel": { "EndPoints": { "Http": { "Url": "http://192.168.69.115:5000" } } }

And followed the docs from Microsoft: https://docs.microsoft.com/en-gb/aspnet/core/fundamentals/servers/kestrel?view=aspnetcore-3.1