statianzo / Fleck

C# Websocket Implementation

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Error on specifying Host Name instead of IP address.

bharath3719 opened this issue · comments

I am running an WAMP router host as an IIS Service.

It works when I do this :

_host = new DefaultWampHost("ws://127.0.0.1:26429/");
_host.Open();

But when I specify my IP address or when I use hostname , it throws an error

ERROR StartService - Excecption occured : System.FormatException: Failed to parse the IP address part of the location. Please make sure you specify a valid IP address. Use 0.0.0.0 or [::] to listen on all interfaces.
---> System.FormatException: An invalid IP address was specified.
---> System.Net.Sockets.SocketException (10022): An invalid argument was supplied.

Remove the forward slash after the port: 26429/".

Still the same error..

if i use the host name "wss://hibcl2020:26429" I get : System.FormatException: Failed to parse the IP address part of the location.

if i use host ip address "wss://xxx.xx.xx.xx:26429" I get: The requested address is not valid in its context.

Try use 0.0.0.0:26429

or otherwise run this bit of code somewhere, maybe c# Interactive panel and see if this fails. This is basically what it's doing under the hood.

var uri = new Uri("wss://127.0.0.1:26429");
Console.WriteLine(uri.Host);  // get an output of 127.0.0.1?
var ip = System.Net.IPAddress.Parse(uri.Host); // this is the bit that seems to be failing for you
Console.WriteLine(ip.ToString());  // get an output of 127.0.0.1?

The above code runs fine. The issue is when i use hostname instead of IP. Is that supported?

Clients(autobahn.js) subscribe to WAMP host. Locally , if we are using 127.0.0.1 as endpoint. It works.

But when multiple clients are subscribing, in a prod env , the client will subscribe based on host name and not local ip address.

Please correct me if I'm wrong.

And if i am using 0.0.0.0:26429 in server to create host , what should i use from client side to connect to the same ?

Server use ip, client use ip or domain name.

Server: "ws://0.0.0.0:26429"
Client: "ws://127.0.0.1:26429" or "ws://my.domain.com:26429"

Example application... #215 (comment)

Thanks for the help. This is what was needed. :)