Valhalla Legends Archive

Programming => Battle.net Bot Development => Topic started by: Eternal on March 23, 2006, 01:44 PM

Title: A question about sockets...I think.
Post by: Eternal on March 23, 2006, 01:44 PM
Hi all,

Would appreciate some advice. If my DSL connection drops (which it seems to do more often than it should, but that's another problem altogether) I notice that my bot just, well sits there. It disconnects, of course, but I am unable to make it autoreconnect unless I try to hit the enter button to send some data, for example. Then, it displays the socket error code and runs the autoreconnect routine I have written. Other bots, like Stealth for example, will display this almost immediately then reconnect.

I just wondered if anyone would offer some pointers on where I should be debugging to see why this is happening. I've tried putting in a few bits of code to run if the socket state (VB6....ewww) is not connected, but it never gets to that point.

Any help much appreciated.

Thanks,

Title: Re: A question about sockets...I think.
Post by: Eric on March 23, 2006, 01:52 PM
Send keep-alive packets and monitor times between SID_PINGs when idle.
Title: Re: A question about sockets...I think.
Post by: Eternal on March 23, 2006, 03:36 PM
Thanks for the reply. I do already send keep alive packets. I'm wondering though how your suggestion will help. Would you mind elaborating?

thanks,
Title: Re: A question about sockets...I think.
Post by: Yegg on March 23, 2006, 04:48 PM
Quote from: Eternal on March 23, 2006, 03:36 PM
Thanks for the reply. I do already send keep alive packets. I'm wondering though how your suggestion will help. Would you mind elaborating?

thanks,

http://bnetdocs.valhallalegends.com/content.php?Section=m&Code=192

I hope you're sending the packets properly. You just need to send 0x00 once, if Battle.net sends it back then you're still connected to them. However you should take Lord's advice and record how long it takes them to respond.
Title: Re: A question about sockets...I think.
Post by: Zakath on March 23, 2006, 05:20 PM
I don't monitor response time at all - networks do suffer problems that will delay responses without shutting down the socket. However, when you disconnect and attempt to send an SID_NULL, you should be immediately getting back an error response indicating the socket is no longer open.
Title: Re: A question about sockets...I think.
Post by: Eternal on March 23, 2006, 05:35 PM
Thanks guys. I've monitored these suggestions and it seems I wasn't sending those packets correctly. Now that I am, once the DSL drops (or once someone removes the cable to test....) the socket error is being received properly and the bot is now reconnecting.

Thanks for your suggestions.
Title: Re: A question about sockets...I think.
Post by: Eric on March 23, 2006, 06:54 PM
Quote from: Zakath on March 23, 2006, 05:20 PM
I don't monitor response time at all - networks do suffer problems that will delay responses without shutting down the socket.

This is true to an extent; however you should still close the socket if no data has been received in over x number of minutes.  IIRC, Battle.net will drop an inactive connection after about 3 minutes.
Title: Re: A question about sockets...I think.
Post by: UserLoser on March 24, 2006, 12:06 AM
Quote from: Lord[nK] on March 23, 2006, 06:54 PM
Quote from: Zakath on March 23, 2006, 05:20 PM
I don't monitor response time at all - networks do suffer problems that will delay responses without shutting down the socket.

This is true to an extent; however you should still close the socket if no data has been received in over x number of minutes.  IIRC, Battle.net will drop an inactive connection after about 3 minutes.

I don't think they drop inactive connections unless something has changed very recently
Title: Re: A question about sockets...I think.
Post by: Eric on March 24, 2006, 12:19 AM
Quote from: UserLoser on March 24, 2006, 12:06 AM
Quote from: Lord[nK] on March 23, 2006, 06:54 PM
Quote from: Zakath on March 23, 2006, 05:20 PM
I don't monitor response time at all - networks do suffer problems that will delay responses without shutting down the socket.

This is true to an extent; however you should still close the socket if no data has been received in over x number of minutes.  IIRC, Battle.net will drop an inactive connection after about 3 minutes.

I don't think they drop inactive connections unless something has changed very recently

I wasn't referring to the chat activity.
Title: Re: A question about sockets...I think.
Post by: UserLoser on March 24, 2006, 12:23 AM
Quote from: Lord[nK] on March 24, 2006, 12:19 AM
Quote from: UserLoser on March 24, 2006, 12:06 AM
Quote from: Lord[nK] on March 23, 2006, 06:54 PM
Quote from: Zakath on March 23, 2006, 05:20 PM
I don't monitor response time at all - networks do suffer problems that will delay responses without shutting down the socket.

This is true to an extent; however you should still close the socket if no data has been received in over x number of minutes.  IIRC, Battle.net will drop an inactive connection after about 3 minutes.

I don't think they drop inactive connections unless something has changed very recently

I wasn't referring to the chat activity.

What are you referring to?  I know during the logon process you can freeze a connection for a long period of time.
Title: Re: A question about sockets...I think.
Post by: Spilled on March 24, 2006, 12:56 AM
Seeming as I have shitty dsl similiar to yours (dropping all the time), I had this same problem and doing what Lord[nK] said by sending keep alive packets is how I fixed this instead of just sending them back when i recieved them =\

I miss cable :(
Title: Re: A question about sockets...I think.
Post by: Eternal on March 24, 2006, 01:28 AM
Quote from: Spilled on March 24, 2006, 12:56 AM
Seeming as I have shitty dsl similiar to yours (dropping all the time), I had this same problem and doing what Lord[nK] said by sending keep alive packets is how I fixed this instead of just sending them back when i recieved them =\

I miss cable :(

My DSL line used to be very solid and stable. Then the modem died and I was sent a replacement by my ISP (same model, Speedtouch). Now I have the disconnect issue, so it makes me think that something with this modem is causing it, maybe. I'll probably replace it for something more robust and see.
Title: Re: A question about sockets...I think.
Post by: Eric on March 24, 2006, 02:44 AM
Quote from: UserLoser on March 24, 2006, 12:23 AM
Quote from: Lord[nK] on March 24, 2006, 12:19 AM
Quote from: UserLoser on March 24, 2006, 12:06 AM
Quote from: Lord[nK] on March 23, 2006, 06:54 PM
Quote from: Zakath on March 23, 2006, 05:20 PM
I don't monitor response time at all - networks do suffer problems that will delay responses without shutting down the socket.

This is true to an extent; however you should still close the socket if no data has been received in over x number of minutes.  IIRC, Battle.net will drop an inactive connection after about 3 minutes.

I don't think they drop inactive connections unless something has changed very recently

I wasn't referring to the chat activity.

What are you referring to?  I know during the logon process you can freeze a connection for a long period of time.

Yes, providing that you reply to SID_PING and/or send SID_NULL every minute or two.
Title: Re: A question about sockets...I think.
Post by: Networks on March 24, 2006, 04:22 PM
Quote from: Eternal on March 24, 2006, 01:28 AM
Quote from: Spilled on March 24, 2006, 12:56 AM
Seeming as I have shitty dsl similiar to yours (dropping all the time), I had this same problem and doing what Lord[nK] said by sending keep alive packets is how I fixed this instead of just sending them back when i recieved them =\

I miss cable :(

My DSL line used to be very solid and stable. Then the modem died and I was sent a replacement by my ISP (same model, Speedtouch). Now I have the disconnect issue, so it makes me think that something with this modem is causing it, maybe. I'll probably replace it for something more robust and see.

It's obviously not your modem since you stated prior that when a disconnect occurs Stealth Bot functions as it should. It's obvious therefore that it's the bot that you are coding is the problem.
Title: Re: A question about sockets...I think.
Post by: Kp on March 24, 2006, 06:38 PM
Quote from: Networks on March 24, 2006, 04:22 PM
Quote from: Eternal on March 24, 2006, 01:28 AM
Quote from: Spilled on March 24, 2006, 12:56 AM
Seeming as I have shitty dsl similiar to yours (dropping all the time), I had this same problem and doing what Lord[nK] said by sending keep alive packets is how I fixed this instead of just sending them back when i recieved them =\

I miss cable :(

My DSL line used to be very solid and stable. Then the modem died and I was sent a replacement by my ISP (same model, Speedtouch). Now I have the disconnect issue, so it makes me think that something with this modem is causing it, maybe. I'll probably replace it for something more robust and see.

It's obviously not your modem since you stated prior that when a disconnect occurs Stealth Bot functions as it should. It's obvious therefore that it's the bot that you are coding is the problem.

It looks like he meant that he used to have a connection which would stay up for very long periods of time.  After his modem was replaced, the connection became prone to dying -- and severing any open TCP streams in the process.  His remarks are entirely irrelevant to the original problem, which was that the client was not detecting the stream had collapsed.
Title: Re: A question about sockets...I think.
Post by: Eternal on March 25, 2006, 02:51 AM
Well said. That's exactly what I was saying. Looks like the whole DSL line issue has just clouded the picture a bit. So, to confirm, my DSL line is nothing to do with the problem, it was just highlighting the issue that I was not sending keep-alive packets correctly, hence the bot would not autoreconnect when my DSL line disconnected.

Thanks to the suggestions here, I have managed to fix the problem.

;D