Vaccano
Vaccano

Reputation: 82437

Use SignalR with IP Address instead of computer name

I have a SignalR service setup to run self hosted in a Windows Service.

When I enter this address:

http://mycomputer.mydomain.net:8789/signalr/signalr/negotiate

I get some xml (for negotiation) displayed in the browser (showing that hit the service correctly.)

But if I enter this address (that has mycomputer.mydomain.net's ip address in place of the computer name):

http://10.92.15.6:8789/signalr/signalr/negotiate

or this

http://localhost:8789/signalr/signalr/negotiate

I get this error:

Bad Request - Invalid Hostname

HTTP Error 400. The request hostname is invalid.

I have tried also using:

http://10.92.15.6.mydomain.net:8789/signalr/signalr/negotiate

But I just get:

This site can’t be reached

10.92.15.6.mydomain.net’s server DNS address could not be found.

Is there someway to be able to make SignalR work using an IP Address instead of the computer name?

Upvotes: 2

Views: 1384

Answers (1)

Vaccano
Vaccano

Reputation: 82437

I had to change my startup from this:

string url = "http://" + machineName + ".mydomain.net:8789";
server = WebApp.Start<Startup>(url);

to this:

string url = "http://*:8789";
var startOptions = new StartOptions(url);
server = WebApp.Start<Startup>(startOptions);

Upvotes: 4

Related Questions