1
Vote

.NET 3.5 Client and DNS names

description

When you try to connect from managed client library (3.5, not 4.0) to service using an url like "ws://mydnshostname:port/websocket" instead of using IP... it fails

Looks like your code or a dependency is downcasting somewhere to base EndPoint instead of using the existing DnsEndPoint class. When accessing m_RemoteEndPoint.AddressFamily from EndPoint an MethodNotImplemented exception is thrown.

It works well with any IP Address in uri like "ws://10.10.10.10:port/websocket"
    public void Connect()
    {
        m_ReceiveAsyncEventArgs.RemoteEndPoint = m_RemoteEndPoint;

if NET35

        m_Socket = new Socket(m_RemoteEndPoint.AddressFamily, SocketType.Stream, ProtocolType.Tcp); // <<<----- HERE IS THE PROBLEM (AddressFamily)
        m_Socket.ConnectAsync(m_ReceiveAsyncEventArgs);

else

        if (!Socket.ConnectAsync(SocketType.Stream, ProtocolType.Tcp, m_ReceiveAsyncEventArgs))
            ProcessConnect(m_ReceiveAsyncEventArgs);

endif

comments

SocialVictim wrote Oct 27, 2011 at 4:22 PM

Have you managed to make it work using DNS names rather than bare IP addresses at ws://address/websocket URI?

At this moment i'm stuck here with this issue.

Any help will be much appreciated

kerryjiang wrote Oct 27, 2011 at 4:53 PM

I'll try to figure it out tomorrow!