Not logged in. · Lost password · Register
Forum: agsXMPP RSS
Avatar
Nicker #1
Member since Feb 2016 · 4 posts
Group memberships: Members
Show profile · Link to this post
Subject: A connection issue was created in revision 151
A connection issue was created in revision: 151 - added ipv6 support, at '\trunk\agsxmpp\Net\Dns\Resolver.cs' line 152
while IPv6 is absent, no router/ISP support, it may take a long time to open a connection.

It seems to happen due to two reasons:
1. There are many tries and retires to open a destined to fail IPv6 connection, in my use case I have many network adapters.
2. Socket.Close() at Resolver.cs line 189 is blocking and takes a few seconds to return.
Avatar
Alex #2
Member since Feb 2003 · 4322 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
Hello Nicker,

Don't understand your problem.
Can you please elaborate, provide a test case or fix?

I have 6 network interfaces on my current machine and no problems.

Alex
Avatar
Nicker #3
Member since Feb 2016 · 4 posts
Group memberships: Members
Show profile · Link to this post
Alex,

If you have a valid IPv6 connectivity, the issue will not reproduce.
it may be checked here: http://ipv6-test.com/

if so try disabling IpV6 in the network adapter or in the router.

This is my test case

  1. public void Connect()
  2. {
  3.     XmppClientConnection connection = fXmpp = new XmppClientConnection();
  4.  
  5.     fXmpp.OnLogin += xmpp_OnLogin;
  6.     fXmpp.OnError += xmpp_OnError;
  7.  
  8.     fXmpp.Server = "gmail.com";
  9.     fXmpp.ConnectServer = "talk.google.com";
  10.     fXmpp.Username = "myUserName";
  11.     fXmpp.Password = "myPassword";
  12.     fXmpp.Open(); // the issue happens here.
  13. }
  14.  
  15. void xmpp_OnError(object sender, Exception ex)
  16. {
  17.  
  18. }
  19. void xmpp_OnLogin(object sender)
  20. {
  21.  
  22. }

THE ISSUE: It takes fXmpp.Open() 1-2 minutes to return.

This doesn't happen with revision 150, meaning it's related to the IpV6.

My IP connectivity results:
[Image: http://s16.postimg.org/dgptp3n0l/conn.png]
This post was edited 2 times, last on 2016-02-11, 10:53 by Alex.
Avatar
Alex #4
Member since Feb 2003 · 4322 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
this is the diff between those version:

Index: Net/Dns/Resolver.cs
===================================================================
--- Net/Dns/Resolver.cs    (revision 150)
+++ Net/Dns/Resolver.cs    (revision 151)
@@ -148,7 +148,11 @@
                 }
 
                 // we'll be send and receiving a UDP packet
-                Socket socket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
+                Socket socket;
+                if (Socket.OSSupportsIPv6 && (server.AddressFamily == AddressFamily.InterNetworkV6))
+                    socket = new Socket(AddressFamily.InterNetworkV6, SocketType.Dgram, ProtocolType.Udp); // V6
+                else
+                    socket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
            
                 // we will wait at most 1 second for a dns reply
                 socket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReceiveTimeout, _udpTimeout);

feel free to suggest a fix
Avatar
Nicker #5
Member since Feb 2016 · 4 posts
Group memberships: Members
Show profile · Link to this post
I'm not a network expert, but AFAIK, IPv6 connectivity is determined using an unreasonable amount of connection timeouts (trial and error).

My suggestions would be as follows:

1. short solution - Adding a new property EnableIPV6, and default it to false.
2. long solution  -  determine IPv6 connectivity only at first run or once per predetermined period of time, for example 1 month.
    save the IP connectivity state to local data, and then read it on startup.
    'EnableIPV6' may be added here as well


I tend to go with the former solution, since I don't see valid reasons to use IPv6.
Avatar
Alex #6
Member since Feb 2003 · 4322 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
with this code you can find out if a network interface support IPv6 (v6 enabled).
But when the socket gets created its not bound to a specific network interface.

  1. NetworkInterface[] allInterfaces = NetworkInterface.GetAllNetworkInterfaces();
  2. NetworkInterface firstInterface = allInterfaces[0];
  3. bool interfaceSupportsIPv6 = firstInterface.Supports(NetworkInterfaceComponent.IPv6);

We have not seen the issue you describe before. Which Windows OS are you using?
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: agsXMPP RSS