kami13sep / jabber-net

Automatically exported from code.google.com/p/jabber-net
Other
0 stars 0 forks source link

Unable to connect to Google Talk #29

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?

I have the following basic code for connecting to gtalk:

JabberClient client = new JabberClient();
client.Server = "gmail.com";
client.User = "alabala";
client.Password = "koko";
client.Connect();

What is the expected output? What do you see instead?

The program is throwing exception when trying to retrieve DNS records
(DnsQuery) - "DNS Query Fails". I have tried to provide the network host by
setting:

client.NetworkHost = "talk.l.google.com";

but then I get a different exception in IPAddress.InternalParse method
saying "An invalid IP address was specified."

I have run the *nslookup* to see what is going on and when following the
instructions at http://code.google.com/p/jabber-net/wiki/FAQ_GoogleTalk
I have problems getting the SRV DNS records. Only after I specify:

set class=ANY

it is able to provide the records.

What version of the product are you using? On what operating system?

Jabber-Net.2005.r1.0.1.msi
jabber-net.dll, 2.0.0.609
netlib.Dns.dll, 1.1.2972.29006

Original issue reported on code.google.com by ivan.p...@gmail.com on 24 Jun 2008 at 8:38

GoogleCodeExporter commented 8 years ago
This sounds like a problem with your DNS server, but we should give better 
errors.  Any chance you could use 
wireshark to grab the related DNS queries?  You can attach the dump file here.

Original comment by hil...@gmail.com on 24 Jun 2008 at 1:53

GoogleCodeExporter commented 8 years ago
Hi,

I have attached capture. You will the see the query is "class IN". The problem 
with
DNS doesn't explain the second issue where I'm trying to specify NetworkHost
property. It looks like the .NET code has issues processing "talk.l.google.com".

Original comment by ivan.p...@gmail.com on 24 Jun 2008 at 4:29

Attachments:

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
I'm still not able to understand what is the issue with DNS. But if we put this
aside, I think there is an issue with "SocketStanzaStream.Connect" method. It
initializes a new object type "bedrock.net.Address" with 2 parameters: hostname 
and
port. So hostname parameter is set to "Hostname" property, which internally is
processed by calling "IPAddress.Parse" method. The problem is that provided 
parameter
is not IP adress like 209.85.163.125, but "talk.l.google.com" and the
"IPAddress.Parse" method obviously fails when used with this. Even the name
"hostname" makes me assume it is not ip address but a host name which has to be
resolved into ip address first.

Original comment by ivan.p...@gmail.com on 24 Jun 2008 at 7:55

GoogleCodeExporter commented 8 years ago
Btw I'm running the code on Windows XP. Could it be that your code is working on
Windows Vista and it is not tested on Windows XP ?

Original comment by ivan.p...@gmail.com on 24 Jun 2008 at 7:58

GoogleCodeExporter commented 8 years ago
One more additional information. I have found the code, which resolves host 
name into
IP address. But it is still failing inside
"bedrock.net.AsyncSocket.OnConnectResolved" method, when it calls
"m_sock.BeginConnect" method below. The error with which it fails is 
"WSAEOPNOTSUPP
10045" - Operation not supported. When I use the JabberClient with "NetworkHost"
property set to the IP address, then it finally works. But using host name 
doesn't work.

Original comment by ivan.p...@gmail.com on 24 Jun 2008 at 9:57

GoogleCodeExporter commented 8 years ago
I'm running XP here.  The fact that nslookup doesn't work is what makes me 
think the problem is your DNS 
server.  There are a *lot* of bad DNS servers out there.  Try using "dig" from 
a Linux or OSX box:

% dig +short -t SRV _xmpp-client._tcp.gmail.com.
5 0 5222 talk.l.google.com.
20 0 5222 talk1.l.google.com.
20 0 5222 talk2.l.google.com.
20 0 5222 talk3.l.google.com.
20 0 5222 talk4.l.google.com.

What I'm seeing in your pcap seems to confirm this.  You're sending out a valid 
request, and getting a 
response that says there are no records.  With NetworkHost set, I bet you're 
getting an error because there is 
no A record being returned.  If you wanted to send me the pcap for the A record 
lookup, we could confirm 
that.

As a work-around, try setting the NetworkHost to 72.14.253.125.

As well, try using head of subversion.  I tried using an invalid hostname on 
head, and it fired the correct error.

Original comment by hil...@gmail.com on 24 Jun 2008 at 10:05

GoogleCodeExporter commented 8 years ago
Wha?  WSAEOPNOTSUPP means you're trying to listen on a UDP socket, or do 
MSG_OOB.  Neither of which I'm 
doing.

Uh... have you tried rebooting? :)

Original comment by hil...@gmail.com on 24 Jun 2008 at 10:08

GoogleCodeExporter commented 8 years ago
I have tried the "dig" command and it returned:

;; connection timed out; no servers could be reached

Regarding the second issue, I rebooted and the issue is still there, so there 
must be
something going on. I have verified the ErrorCode and it is 10045.

The thing that is bothering me is that I don't have issues whatsoever with the
standard Google Talk client. Should I try another client like PSI? Any other 
suggestion?

Original comment by ivan.p...@gmail.com on 25 Jun 2008 at 2:37

GoogleCodeExporter commented 8 years ago
The GoogleTalk client likely has an internal fallback to a specific IP address 
if DNS doesn't work.  They can do 
that since they are tied to a particular service, and don't have to talk to 
other servers.

I bet if you do a wireshark trace of that client starting up, you'll see the 
same DNS queries, failing the exact 
same way.

Original comment by hil...@gmail.com on 25 Jun 2008 at 2:58

GoogleCodeExporter commented 8 years ago
Okay. I have upgraded my router and now it is able to retrieve the SRV records
properly. The problem with error 10045 (WSAEOPNOTSUPP) is still there. I have 
tested
the PSI client and it works fine. Another problem I'm seeing is that the 
exception is
happening in another thread (the async communication) and I'm unable to catch 
it and
the whole application is failing. I will investigate the code and see if I'm 
able to
find something.

Original comment by ivan.p...@gmail.com on 25 Jun 2008 at 5:09

GoogleCodeExporter commented 8 years ago
I don't if this will help, but the code fails in
"System.Net.Sockets.Socket.ConnectEx" when it calls
UnsafeNclNativeMethods.OSSOCK.WSAIoctl.

Original comment by ivan.p...@gmail.com on 25 Jun 2008 at 5:53

GoogleCodeExporter commented 8 years ago
Finally I have fixed the second issue. It looks like I had some kind of Winsock
corruption. You may find this discussion useful:

http://forums.msdn.microsoft.com/en-US/netfxnetcom/thread/687d9379-924a-48c3-9a0
1-0f22805c3c9b/

And also this KB from MS was what resolved the issue for me:
http://support.microsoft.com/default.aspx?scid=kb%3Ben-us%3B811259

Probably it would be a good idea to include information about this in the FAQ 
because
it appears other people have experienced problems with sockets used in 
asynchronous
scenarios. It was usually related to winsock been corrupted by firewalls like 
McAfee
and Norton.

Original comment by ivan.p...@gmail.com on 25 Jun 2008 at 6:51

GoogleCodeExporter commented 8 years ago
So, was the gist that you did:

netsh winsock reset

and everything worked fine?  If that's the case, yes, I'll just write an FAQ 
entry and close this ticket.

Original comment by hil...@gmail.com on 25 Jun 2008 at 9:41

GoogleCodeExporter commented 8 years ago
At the KB link I have sent you there is a "Guided Help" application, which I 
have
executed. It did remove and reinstall the TCPIP protocol support. And it now 
works
properly.

Original comment by ivan.p...@gmail.com on 25 Jun 2008 at 9:47

GoogleCodeExporter commented 8 years ago
OK, new wiki page here: http://code.google.com/p/jabber-net/wiki/SocketErrors

We'll collect other oddnesses there over time.

Original comment by hil...@gmail.com on 25 Jun 2008 at 10:06