I want to implement chat in my android app using SignalR and I download this example from asp.net: https://www.asp.net/signalr/overview/getting-started/tutorial-getting-started-with-signalr But I can't acces to it using localhost through HubConnection. I tried using my IP adress and port number but it's not working. Does anyone has experience with this?
Thanks!
Assuming your app server is IIS Express, it won´t work by default because of network restrictions or even the firewall.
First thing, as you already realized, the client needs to connect with your machine ip, not localhost. Something like
http://x.x.x.x:port/signalr
Then you need to make sure your machine is accesible from the mobile phone or emulator: open a browser in the phone and type a known address, like
http://x.x.x.x:port/somethingThatExists
.If that url is not available:
Open powershell at the machine runing IIS-Express and run this:
netsh http add urlacl url=http://{your server ip}:{port}/ user=everyone
. (if your system language is not english, for instance: spanish, change "everyone" to "todos")Open the file
applicationhost.config
in your directory solutionSolution/.vs/config/applicationhost.config
and search for the application xml node. Something like<site name="YourAppName" id="1">...</site>
. You´ll see thelocalhost
binding by default. Add a new one with the actual ip:<binding protocol="http" bindinginformation="*:port:x.x.x.x"></binding>
(make sure the ip/port are correct. i.e:*:57457:192.168.0.57
)Restart IIS Express and try again (no need to reboot the system)