Not logged in. · Lost password · Register
Forum: MatriX RSS
Avatar
apaulus #1
Member since Aug 2017 · 12 posts
Group memberships: Members
Show profile · Link to this post
Subject: Matrix.vNext: connect to chat server on different port than 5222
We use the following code to connect to our chat server on port 80:

  1. var client = new XmppClient
  2. {
  3.         Username = "testuser",
  4.         Password = "somepassword",
  5.         Port = 80,
  6.         XmppDomain = "localhost",
  7. };
  8.  
  9. await client.ConnectAsync();

I have configured a prosody server to run locally only on port 80. The code throws a
  1. System.Net.Sockets.SocketException (0x80004005): No connection could be made because the target machine actively refused it
  2.    at DotNetty.Transport.Channels.Sockets.SocketChannelAsyncOperation.Validate()

Navigating through the DotNetty stacktrace (in ) I could find the following interesting fact:

In DotNetty.Transport.dll!DotNetty.Transport.Channels.Sockets.TcpSocketChannel.DoFinishConnect(DotNetty.Transport.Channels.Sockets.SocketChannelAsyncOperation operation) the RemoteEndPoint property of the operation was set to {[::1]:5222} so it seems like the port was not propagated properly.

Thanks in advance for looking into this!

Cheers,
apaulus
This post was edited on 2017-10-09, 14:30 by apaulus.
Avatar
Alex #2
Member since Feb 2003 · 4327 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
we debug with local Prosody installations often and don't have any problems there.
This can be also a ipv4/ipv6 issue.

Try to add a resolver which points to your correct local IP.
  1. xmppClient.HostnameResolver = new StaticNameResolver(prosodyIp, prosodyPort);
  2. // or
  3. xmppClient.HostnameResolver = new StaticNameResolver(IPAddress.Parse("127.0.0.1"), 5222),

often times local servers listen either on v4 or v6, and localhost gets resoved to your local v6 IP.
While the server may listen only on v4 and the IP 127.0.0.1.
This post was edited on 2017-10-09, 14:38 by Alex.
Avatar
apaulus #3
Member since Aug 2017 · 12 posts
Group memberships: Members
Show profile · Link to this post
You are right, localhost gets resolved to my v6 IP.

I have added the port to the StaticNameResolver and now it works, thank you!

Could it be that the port settings are overwriting each other here? https://imgur.com/CSnlKEb

Thanks again for the lightning fast response  :-D
Avatar
Alex #4
Member since Feb 2003 · 4327 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
yes the Port property on XmppClient is obsolete when you use a StaticNameResolver.
Avatar
apaulus #5
Member since Aug 2017 · 12 posts
Group memberships: Members
Show profile · Link to this post
thanks for clarifying this :)
Close Smaller – Larger + Reply to this post:
Verification code: VeriCode Please enter the word from the image into the text field below. (Type the letters only, lower case is okay.)
Smileys: :-) ;-) :-D :-p :blush: :cool: :rolleyes: :huh: :-/ <_< :-( :'( :#: :scared: 8-( :nuts: :-O
Special characters:
Forum: MatriX RSS