mIRC Homepage

New mIRC taking much longer on opening sockets

Posted By: HaleyJ

New mIRC taking much longer on opening sockets - 23/08/10 07:16 PM

Hi all,

I have just noticed that my sockets are taking ages to open. I then realised it is only since I downloaded the new version. I have used this code on mIRC 6.35 and on mIRC 7.1 and got two vastly different results.

Code:
alias test_socket {
  set -e %socket_time $ticks
  sockopen test_socket www.google.com 80 
}
on *:sockopen:test_socket:{ 
  echo $color(info) -a It took  $calc(($ticks - %socket_time) / 1000) seconds for $sockname to open.
  unset %socket_time 
  sockclose $sockname
}


mIRC 7.1 returned It took 15.031 seconds for test_socket to open.

mIRC 6.35 returned It took 0.078 seconds for test_socket to open.

I find it very troubling, and wonder what the problem could be.
Posted By: drum

Re: New mIRC taking much longer on opening sockets - 23/08/10 07:33 PM

Can you identify whether the connection is successful or not? What error (if any) is reported if you use this code?

Code:
alias test_socket {
  set -e %socket_time $ticks
  sockopen test_socket www.google.com 80 
}
on *:sockopen:test_socket:{
  echo -a Time: $calc(($ticks - %socket_time) / 1000) seconds
  unset %socket_time 
  if ($sockerr > 0) {
    echo -a Connection failed: $sockerr / $sock($sockname).wsmsg
    return
  }
  echo -a Connection successful
  sockclose $sockname
}
Posted By: STING

Re: New mIRC taking much longer on opening sockets - 23/08/10 07:33 PM

Can't reproduce it here.
7.1 is slower, but not noticable.

Do you have the UPnP settings enabled?

mIRC 7.1:
It took 0.063 seconds for test_socket to open.
It took 0.062 seconds for test_socket to open.
It took 0.078 seconds for test_socket to open.
It took 0.062 seconds for test_socket to open.
It took 0.062 seconds for test_socket to open.
It took 0.063 seconds for test_socket to open.
It took 0.078 seconds for test_socket to open.
It took 0.062 seconds for test_socket to open.
It took 0.078 seconds for test_socket to open.
It took 0.062 seconds for test_socket to open.
It took 0.078 seconds for test_socket to open.
It took 0.062 seconds for test_socket to open.
It took 0.078 seconds for test_socket to open.
It took 0.062 seconds for test_socket to open.

mIRC 6.35:
It took 0.032 seconds for test_socket to open.
It took 0.047 seconds for test_socket to open.
It took 0.046 seconds for test_socket to open.
It took 0.032 seconds for test_socket to open.
It took 0.046 seconds for test_socket to open.
It took 0.047 seconds for test_socket to open.
It took 0.031 seconds for test_socket to open.
It took 0.031 seconds for test_socket to open.
It took 0.047 seconds for test_socket to open.
It took 0.031 seconds for test_socket to open.
It took 0.031 seconds for test_socket to open.
It took 0.031 seconds for test_socket to open.
Posted By: Wims

Re: New mIRC taking much longer on opening sockets - 23/08/10 07:49 PM

Can't reproduce this either with OP code, it makes sense to me that the connexion is successful since it get a result
Posted By: drum

Re: New mIRC taking much longer on opening sockets - 23/08/10 07:52 PM

Originally Posted By: Wims
Can't reproduce this either with OP code, it makes sense to me that the connexion is successful since it get a result


The ON SOCKOPEN event will be triggered even if the connection fails. You must check $sockerr to find out.
Posted By: Wims

Re: New mIRC taking much longer on opening sockets - 23/08/10 07:54 PM

Oops, that's true.
Posted By: HaleyJ

Re: New mIRC taking much longer on opening sockets - 23/08/10 08:08 PM

I can confirm that the socket does open successfully.

mIRC 7.1 Returns

Time: 15.047 seconds
Connection successful

mIRC 6.35 Returns

Time: 0.031 seconds
Connection successful



Posted By: Riamus2

Re: New mIRC taking much longer on opening sockets - 23/08/10 09:17 PM

You didn't mention if you have upnp enabled. That is most likely the cause.
Posted By: Khaled

Re: New mIRC taking much longer on opening sockets - 23/08/10 09:23 PM

I have not been able to reproduce this so far. The connection is immediate in my tests. Which version of Windows are you using?

UPnP is unlikely to be the cause of any issues since UPnP is only used when mIRC needs to listen for an incoming connection not when opening an outgoing connection. However you can try disabling UPnP in the Options/Connect/Options/Ports dialog to see if that helps.

Also in the Ports dialog, if you disable the Port Range options, does that help?
Posted By: HaleyJ

Re: New mIRC taking much longer on opening sockets - 24/08/10 08:40 AM

Hi,

Sorry for taking so long to reply.

I am using Windows XP Pro

I went to options/ports in 7.1 and could not find how to disable the range. I have enclosed a screenshot below, unless you want me to clear both boxes? not sure what you meant.

Also disabling uPNP had no effect!

Even if it is upnp why is mIRC6.35 not affected?

Many thanks.

http://img412.imageshack.us/img412/5692/mircscreenshot.jpg

Posted By: tontito

Re: New mIRC taking much longer on opening sockets - 24/08/10 02:51 PM

version 6.35 has no upnp support, that is why we were talking about it.
Posted By: Khaled

Re: New mIRC taking much longer on opening sockets - 24/08/10 06:36 PM

Yes, if you could uncheck all boxes in the "Port Range" section and then let us know if that helps.
Posted By: HaleyJ

Re: New mIRC taking much longer on opening sockets - 24/08/10 07:23 PM

Hi there,

Just did that and still get the same problem.

Time: 15.063 seconds
Connection successful

Regards,
Posted By: starbucks_mafia

Re: New mIRC taking much longer on opening sockets - 24/08/10 07:40 PM

Have you tried disabling any anti-virus or firewall software that may be hampering mIRC in the name of security?

It could be you've added mIRC 6.35 to a whitelist previously.
Posted By: HaleyJ

Re: New mIRC taking much longer on opening sockets - 24/08/10 08:21 PM

Hi starbucks,

I disabled windows firewall, and my AV, still the same result. I did the same with my routers firewall etc.

Take in mind mIRC 6.35 opens sockets instantly.

If it helps to debug I am happy for you to connect to my machine.

-

Time: 15.047 seconds
Connection successful

Its always seems to be round the 15 second mark for some reason.

Posted By: STING

Re: New mIRC taking much longer on opening sockets - 25/08/10 11:05 AM

Maybe it's an option to use a network analyzer like Wireshark, to see what the difference in behaviour is between 6.35 & 7.1.
Posted By: BhaaL

Re: New mIRC taking much longer on opening sockets - 25/08/10 04:11 PM

I also noticed this with my HTTP-Check script (checks an URL and tells me the title, or whether it redirects to a potentially dangerous site).

6.35 was pretty quick, 7.1 takes considerably longer. I also noticed this with /dns queries, so I think it might be related to that (remember that IPv6 is now available from within mIRC).

UPnP is disabled, all ports in the configuration are unchecked, and I don't have a firewall that could affect this.
Posted By: HaleyJ

Re: New mIRC taking much longer on opening sockets - 25/08/10 06:23 PM

Originally Posted By: BhaaL
I also noticed this with my HTTP-Check script (checks an URL and tells me the title, or whether it redirects to a potentially dangerous site).

6.35 was pretty quick, 7.1 takes considerably longer. I also noticed this with /dns queries, so I think it might be related to that (remember that IPv6 is now available from within mIRC).

UPnP is disabled, all ports in the configuration are unchecked, and I don't have a firewall that could affect this.


Could you tell us the result when you execute the following code, both in 6.35 and in 7.1

Code:
alias test_socket {
  set -e %socket_time $ticks
  sockopen test_socket www.google.com 80 
}
on *:sockopen:test_socket:{
  echo -a Time: $calc(($ticks - %socket_time) / 1000) seconds
  unset %socket_time 
  if ($sockerr > 0) {
    echo -a Connection failed: $sockerr / $sock($sockname).wsmsg
    return
  }
  echo -a Connection successful
  sockclose $sockname
}


Usage /test_socket
Posted By: BhaaL

Re: New mIRC taking much longer on opening sockets - 26/08/10 04:43 PM

Code:
Time: 0.172 seconds
Connection successful


I did some testing with /dns using the same piece of code (except /dns instead of /sockopen, and on DNS instead of on SOCKOPEN). The first request for a domain takes 10+ seconds, the following ones are quick (cached?)
I guess its the same thing when doing /sockopen domain.tld instead, since someone needs to resolve the IP first.
Posted By: 5618

Re: New mIRC taking much longer on opening sockets - 26/08/10 04:45 PM

Originally Posted By: BhaaL
I guess its the same thing when doing /sockopen domain.tld instead, since someone needs to resolve the IP first.
Which obviously means his tests should be as fast as in 6.35 when he uses one of the IPs of www.google.com
We'll see...
Posted By: HaleyJ

Re: New mIRC taking much longer on opening sockets - 26/08/10 04:57 PM

Originally Posted By: BhaaL
Code:
Time: 0.172 seconds
Connection successful


I did some testing with /dns using the same piece of code (except /dns instead of /sockopen, and on DNS instead of on SOCKOPEN). The first request for a domain takes 10+ seconds, the following ones are quick (cached?)
I guess its the same thing when doing /sockopen domain.tld instead, since someone needs to resolve the IP first.


Was this done in 7.1 or 6.35?
Posted By: Khaled

Re: New mIRC taking much longer on opening sockets - 26/08/10 06:28 PM

The new version of mIRC asks Windows to return both IPv4 and IPv6 addresses for a domain name. It could be that for some users resolving IPv6 is slower than for other users for some reason. It is possible that the delay could be due to an ISPs name servers or your Windows configuration. I will change the DNS lookup in the next version so that it only asks for IPv6 if you have explicitly requested it by using/enabling features that need it.
Posted By: BhaaL

Re: New mIRC taking much longer on opening sockets - 27/08/10 02:10 PM

Originally Posted By: HaleyJ
Was this done in 7.1 or 6.35?

7.1

Khaled: I'm on Windows 7, but I don't have any IPv6-capable interfaces other than loopback; the rest only gets IPv4. And I'd say it will still take some time until my ISP offers IPv6.
Making the request more explicit is IMO a good idea - just like the old one used to be and the new one has its switches for:
IPv4: /dns domain.tld or /dns -4 domain.tld
IPv6: /dns -6 domain.tld
both: /dns -46 domain.tld
Posted By: beware

Re: New mIRC taking much longer on opening sockets - 03/09/10 06:29 PM

My ideas about this problem:

Other apps can do IPv4/IPv6 resolution correctly, without such delays, and without the explicit need to enable IPv6. So it Can Be Done. This is the given, which we have to work with. So what's wrong? How do we fix it properly?

A likely cause of the problem is broken home NAT boxes which don't respond to AAAA queries at all, then mIRC times out after 15 seconds or so.

The recommended way to do DNS resolution is to use getaddrinfo(), the standard API lookup. I checked that this lookup, whereever i tried (both linux and windows), completely omits the AAAA lookup, if the PC has no IPv6 connectivity. This is done, explicitly, as a workaround for such broken NAT routers. If using getaddrinfo is impossible, then omit the AAAA lookup if IPv6 connectivity lacks. To know if you have IPv6 connectivity, look for the presence of global scope IPv6 addresses.

edit: i remember/read elsewhere that you do use getaddrinfo(), but you manually resolve v4 and v6 on their own. first, i advise against this, because the OS is designed to do this properly, taking care of all the edge cases, to make ipv6 work *without problems*. you're misusing the API. secondly, because you manually do v4 and v6 lookups independently, the above applies.
Posted By: Khaled

Re: New mIRC taking much longer on opening sockets - 03/09/10 11:16 PM

Thanks for the comments, however mIRC resolves IPv4 and IPv6 separately because testing showed that the API is broken and behaves differently under different versions of Windows. I think I may have mentioned that in a previous post. In any case, as I indicated in my above reply, this issue has been resolved for the next version.
Posted By: beware

Re: New mIRC taking much longer on opening sockets - 23/09/10 07:51 AM

resolved by explicitly requiring one to state that it's ipv6 with a -6 flag? do you intend this to be the long term solution?

in another thread you said you had difficulty with the idea of checking for ipv6 connectivity, saying you'd have to connect to some internet server for it. can you comment on the idea of looking for the presence of global scope ipv6 addresses? i can test things on XP and vista (and linux) if it helps.
Posted By: Khaled

Re: New mIRC taking much longer on opening sockets - 23/09/10 07:57 AM

This was resolved by making sure that mIRC only resolves IPv6 connections when necessary, eg. if mIRC is binding to an IPv6 address, or if IPv6 support has been enabled in the ports dialog, or if you are using the -6 switches, and so on. As far as I am aware, this covers all of the situations where IPv6 can be used. If I have missed one, or if it is not working for you, please let me know.
© 2019 mIRC Discussion Forums