Valhalla Legends Forums Archive | Battle.net Bot Development | Creating D2 Game

AuthorMessageTime
OnlyMeat
iv been having problems trying to create a d2 game, specifically the problem occurs at the end of this sequence i wrote based on analysis of the real clients packets:-

(1) C-->S 0x03 (Realm)
(2) S-->C 0x03 (Realm)
(3) C-->S 0x04 (Realm)
(4) C-->S 0x1c (Chat)
(5) S-->C 0x04 (Realm) - This contains the IP address of the D2 game server
(6) C-->S 0x22 (Chat) - Notify
(7) C-->S 0x10 (Chat) - LeaveChat
(8) Shutdown realm socket - (Real client appears to do this not sure why??)
(9) Connect to the D2 Game Server - (This is were the problem occurs the socket returns an error specifying that the server actively refused the connnection, the ip address seems ok that it's passing me i.e it's in the bnet servers range and i can ping it and get response and im not ip banned.)

I am a little puzzled by this to say the least i have checked and rechecked a number of times the procedure that the real client appears to use but no luck.

I dont know if any of you guys has done maybe some work on this procedure and could shed some light on the details and//or if im doing something wrong, btw before you ask i tried not disconnecting the realm before connecting to the D2GS and other combinations.

Also im assuming that the D2GS is tcp/ip and has a fixed port of 0xfa0.
July 11, 2004, 6:07 AM
Soul Taker
Try sending 0x13 to the realm before leaving chat. The packet contains no data.
July 11, 2004, 3:57 PM
OnlyMeat
[quote author=Soul Taker link=board=17;threadid=7654;start=0#msg69691 date=1089561426]
Try sending 0x13 to the realm before leaving chat. The packet contains no data.
[/quote]

Ok i tried sending 0x13 to the realm just before sending 0x10 (leaving chat) but it still refuses the connection :(

The thing is it sends the 0x04 response with the D2GS IP so i must be doing that part right so i cant understand why it's refusing the connection.

Anymore ideas?
July 11, 2004, 5:51 PM
kamakazie
Post a packet log of the connection (relevant packets) along with the IP address and port of the D2GS you are connecting to.
July 11, 2004, 7:34 PM
OnlyMeat
[quote author=dxoigmn link=board=17;threadid=7654;start=0#msg69758 date=1089574470]
Post a packet log of the connection (relevant packets) along with the IP address and port of the D2GS you are connecting to.
[/quote]

Game Name: hbrbkav
Password: 1

Packet Log:-

[code]
SEND 83.100.132.198 ----> 213.248.106.208 | Realm 0x03 (Create Game)
17 00 03 02 00 00 00 00 00 01 FF 08 68 62 72 62 6B 61 76 00 31 00 00

RECV 83.100.132.198 <---- 213.248.106.208 | Realm 0x03 (Create Game)
0D 00 03 02 00 41 03 00 00 00 00 00 00

SEND 83.100.132.198 ----> 213.248.106.208 | Realm 0x04 (Join Game)
0F 00 04 CB 00 68 62 72 62 6B 61 76 00 31 00

SEND 83.100.132.198 ----> 213.248.106.202 | Chat 0x1c (Create Game)
FF 1C 23 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 68 62 72 62 6B 61 76 00 31 00 00

RECV 83.100.132.198 <---- 213.248.106.208 | Realm 0x04 (Contains D2GS IP: 213.248.106.92, Use Fixed Port 0xfa0)
15 00 04 CB 00 41 03 00 00 D5 F8 6A 5C 3C 34 EB 0F 00 00 00 00

SEND 83.100.132.198 ----> 213.248.106.202 | Chat 0x22 (Notify)
FF 22 16 00 50 58 32 44 0A 00 00 00 68 62 72 62 6B 61 76 00 31 00

SEND 83.100.132.198 ----> 213.248.106.208 | Realm 0x13 (**Soul Taker**)
03 00 13

SEND 83.100.132.198 ----> 213.248.106.202 | Chat 0x10 (Leave Chat)
FF 10 04 00
[/code]

At the end of this sequence I shutdown the realm socket and attempt to connect to the D2GS server 213.248.106.92
using the fixed port 0xfa0, this then fails and returns a socket error after about 8 seconds specifying that "the target machine actively refused the connection".

Here is my in program log:-

Connected to europe.battle.net
Connecting to realm
Joining realm: europe
Logging in character: xxxx
Joining channel: Diablo II Europe-GBR-1
Welcome to Battle.net!
This server is hosted by Telia.
There are currently 86040 users playing 57453 games of Diablo II Lord of Destruction, and 212259 users playing 80121 games on Battle.net.
Last logon: Mon Jul 12 1:53 PM
Joining channel: op xxx
Creating game: hbrbkav...
Joining game server: 213.248.106.92 on Port: 0xfa0
Socket Error: No connection could be made because the target machine actively refused it.

Disconnected from europe.battle.net
July 12, 2004, 7:06 PM
PaiD
well I almost have the same problem. When I connect to d2gs I cant get into the game due to me not sendin a packet I need to send to offically get into it. I do want to know why you disconnect the mcp socket
July 12, 2004, 7:58 PM
kamakazie
[quote author=OnlyMeat link=board=17;threadid=7654;start=0#msg70002 date=1089659217]
[quote author=dxoigmn link=board=17;threadid=7654;start=0#msg69758 date=1089574470]
Post a packet log of the connection (relevant packets) along with the IP address and port of the D2GS you are connecting to.
[/quote]

Game Name: hbrbkav
Password: 1

Packet Log:-

[code]
SEND 83.100.132.198 ----> 213.248.106.208 | Realm 0x03 (Create Game)
17 00 03 02 00 00 00 00 00 01 FF 08 68 62 72 62 6B 61 76 00 31 00 00

RECV 83.100.132.198 <---- 213.248.106.208 | Realm 0x03 (Create Game)
0D 00 03 02 00 41 03 00 00 00 00 00 00

SEND 83.100.132.198 ----> 213.248.106.208 | Realm 0x04 (Join Game)
0F 00 04 CB 00 68 62 72 62 6B 61 76 00 31 00

SEND 83.100.132.198 ----> 213.248.106.202 | Chat 0x1c (Create Game)
FF 1C 23 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 68 62 72 62 6B 61 76 00 31 00 00

RECV 83.100.132.198 <---- 213.248.106.208 | Realm 0x04 (Contains D2GS IP: 213.248.106.92, Use Fixed Port 0xfa0)
15 00 04 CB 00 41 03 00 00 D5 F8 6A 5C 3C 34 EB 0F 00 00 00 00

SEND 83.100.132.198 ----> 213.248.106.202 | Chat 0x22 (Notify)
FF 22 16 00 50 58 32 44 0A 00 00 00 68 62 72 62 6B 61 76 00 31 00

SEND 83.100.132.198 ----> 213.248.106.208 | Realm 0x13 (**Soul Taker**)
03 00 13

SEND 83.100.132.198 ----> 213.248.106.202 | Chat 0x10 (Leave Chat)
FF 10 04 00
[/code]

At the end of this sequence I shutdown the realm socket and attempt to connect to the D2GS server 213.248.106.92
using the fixed port 0xfa0, this then fails and returns a socket error after about 8 seconds specifying that "the target machine actively refused the connection".

Here is my in program log:-

Connected to europe.battle.net
Connecting to realm
Joining realm: europe
Logging in character: xxxx
Joining channel: Diablo II Europe-GBR-1
Welcome to Battle.net!
This server is hosted by Telia.
There are currently 86040 users playing 57453 games of Diablo II Lord of Destruction, and 212259 users playing 80121 games on Battle.net.
Last logon: Mon Jul 12 1:53 PM
Joining channel: op xxx
Creating game: hbrbkav...
Joining game server: 213.248.106.92 on Port: 0xfa0
Socket Error: No connection could be made because the target machine actively refused it.

Disconnected from europe.battle.net

[/quote]

[quote]
SEND 83.100.132.198 ----> 213.248.106.208 | Realm 0x13 (**Soul Taker**)
03 00 13
[/quote]

0x13 tells the server to cancel the game IIRC. Don't send this and you should be fine.
July 12, 2004, 8:00 PM
OnlyMeat
hmm iv been told to try 0x13 to fix the problem originally, I could do with some consistant answers or ideas please.

I will say now sending 0x13 does not make any difference i still get the same socket error.

Surely someone must have done this procedure before i mean it's not that complicated except for the fact that the D2GS rejects the connection.

The reason i shutdown the realm socket is that if you watch the active connections the real client maintains once it creates a game it appears to close the realm connection and open a new one to the D2GS at almost the same time, of course i cant be sure of this but it certainly looks that way from my analysis.
July 12, 2004, 9:37 PM
kamakazie
[quote author=OnlyMeat link=board=17;threadid=7654;start=0#msg70024 date=1089668265]
hmm iv been told to try 0x13 to fix the problem originally, I could do with some consistant answers or ideas please.

I will say now sending 0x13 does not make any difference i still get the same socket error.

Surely someone must have done this procedure before i mean it's not that complicated except for the fact that the D2GS rejects the connection.

The reason i shutdown the realm socket is that if you watch the active connections the real client maintains once it creates a game it appears to close the realm connection and open a new one to the D2GS at almost the same time, of course i cant be sure of this but it certainly looks that way from my analysis.
[/quote]

Try leaving the connection to the MCP (realm) open.
July 12, 2004, 9:55 PM
OnlyMeat
[quote author=dxoigmn link=board=17;threadid=7654;start=0#msg70028 date=1089669308]
[quote author=OnlyMeat link=board=17;threadid=7654;start=0#msg70024 date=1089668265]
hmm iv been told to try 0x13 to fix the problem originally, I could do with some consistant answers or ideas please.

I will say now sending 0x13 does not make any difference i still get the same socket error.

Surely someone must have done this procedure before i mean it's not that complicated except for the fact that the D2GS rejects the connection.

The reason i shutdown the realm socket is that if you watch the active connections the real client maintains once it creates a game it appears to close the realm connection and open a new one to the D2GS at almost the same time, of course i cant be sure of this but it certainly looks that way from my analysis.
[/quote]

Try leaving the connection to the MCP (realm) open.
[/quote]

Ye i tried that :(
July 12, 2004, 10:09 PM
Soul Taker
[quote author=dxoigmn link=board=17;threadid=7654;start=0#msg70007 date=1089662445]
0x13 tells the server to cancel the game IIRC. Don't send this and you should be fine.
[/quote]
No. My client, and real D2 clients, send 0x13 after recieving 0x04 and before connecting to the game server.
July 12, 2004, 10:10 PM
kamakazie
[quote author=Soul Taker link=board=17;threadid=7654;start=0#msg70034 date=1089670208]
[quote author=dxoigmn link=board=17;threadid=7654;start=0#msg70007 date=1089662445]
0x13 tells the server to cancel the game IIRC. Don't send this and you should be fine.
[/quote]
No. My client, and real D2 clients, send 0x13 after recieving 0x04 and before connecting to the game server.
[/quote]

Hmm, it's been a while since I've done anything relating to creating games in D2.
July 12, 2004, 10:36 PM
Myndfyr
[quote author=dxoigmn link=board=17;threadid=7654;start=0#msg70048 date=1089671808]
Hmm, it's been a while since I've done anything relating to creating games in D2.
[/quote]
Yay for pointlessly being unhelpful... [me=Myndfyre]sighs[/me]

[quote author=OnlyMeat link=board=17;threadid=7654;start=0#msg70024 date=1089668265]
The reason i shutdown the realm socket is that if you watch the active connections the real client maintains once it creates a game it appears to close the realm connection and open a new one to the D2GS at almost the same time, of course i cant be sure of this but it certainly looks that way from my analysis.
[/quote]
What makes you think so? I've never actually done this, but reading this conjecture got me thinking. If Windows is closing a socket and opening a new one to the D2GS, then it seems to me that the port numbers on your side would be different. Honestly, that's the only thing I could think of (aside from differing SYN/ACK sequence IDs, I guess) that would tip me off to it being a different socket.

Hope that helps.
July 12, 2004, 10:46 PM
kamakazie
[quote author=Myndfyre link=board=17;threadid=7654;start=0#msg70049 date=1089672379]
[quote author=dxoigmn link=board=17;threadid=7654;start=0#msg70048 date=1089671808]
Hmm, it's been a while since I've done anything relating to creating games in D2.
[/quote]
Yay for pointlessly being unhelpful... [me=Myndfyre]sighs[/me]
[/quote]

Please enlighten us with your knowledge of the protocol.
July 12, 2004, 11:12 PM
OnlyMeat
Seems no one on here knows how to do it//or wants to share their knowledge so ill try and hunt down some c++ source for it instead.
July 13, 2004, 4:20 AM
UserLoser.
[quote author=OnlyMeat link=board=17;threadid=7654;start=0#msg70130 date=1089692452]
Seems no one on here knows how to do it//or wants to share their knowledge so ill try and hunt down some c++ source for it instead.
[/quote]

AFAIK, there's not much you can do about this error ("No connection could be made because the target machine actively refused it.") Are you sure you're using a TCP socket, not UDP?
July 13, 2004, 6:03 AM
Maddox
[quote author=UserLoser. link=board=17;threadid=7654;start=15#msg70138 date=1089698601]
[quote author=OnlyMeat link=board=17;threadid=7654;start=0#msg70130 date=1089692452]
Seems no one on here knows how to do it//or wants to share their knowledge so ill try and hunt down some c++ source for it instead.
[/quote]

AFAIK, there's not much you can do about this error ("No connection could be made because the target machine actively refused it.") Are you sure you're using a TCP socket, not UDP?
[/quote]

You can't get that error with UDP. UDP is "connectionless."
July 13, 2004, 6:37 AM
Myndfyr
[quote author=OnlyMeat link=board=17;threadid=7654;start=0#msg70130 date=1089692452]
Seems no one on here knows how to do it//or wants to share their knowledge so ill try and hunt down some c++ source for it instead.
[/quote]

Yes! Don't try to figure it out for yourself! Instead, copy someone else's work!
July 13, 2004, 6:02 PM
kamakazie
[quote author=Myndfyre link=board=17;threadid=7654;start=15#msg70201 date=1089741779]
[quote author=OnlyMeat link=board=17;threadid=7654;start=0#msg70130 date=1089692452]
Seems no one on here knows how to do it//or wants to share their knowledge so ill try and hunt down some c++ source for it instead.
[/quote]

Yes! Don't try to figure it out for yourself! Instead, copy someone else's work!
[/quote]

I think we need to start following the mantra, "If you don't have anything nice to say, then don't say anything at all." You, as well as other people, frequently attack (usually in some pseudo-sarcastic way) others like such and it's quite annoying, especially in the Bot Development forum. I don't mean to moderate, but this is a place where people come to be helped not ridiculed.
July 13, 2004, 6:39 PM
Myndfyr
I usually don't do this... but I'm in a bad mood today.

[quote author=dxoigmn link=board=17;threadid=7654;start=15#msg70206 date=1089743947]
I think we need to start following the mantra, "If you don't have anything nice to say, then don't say anything at all." You, as well as other people, frequently attack (usually in some pseudo-sarcastic way) others like such and it's quite annoying, especially in the Bot Development forum. I don't mean to moderate, but this is a place where people come to be helped not ridiculed.
[/quote]
[quote author=dxoigmn link=board=17;threadid=7654;start=0#msg70057 date=1089673977]
Please enlighten us with your knowledge of the protocol.
[/quote]

Note that in the post to which you were referring (about the protocol knowledge), I posted that 1.) I didn't know about the protocol, but 2.) I did try to attempt at a helpful suggestion.

Also, being sarcastic in this sense is an attempt to get him to do something for himself -- to better himself -- than to just dissect someone else's code.

Granted, there are occasions where it's allright to do this. But, we haven't begun to get in-depth and perplexed by this problem enough to warrant going to search for code. On the other hand, this thread was dead enough to warrant bantering. :P

On top of other stuff, don't tell me that I'm unhelpful. I give a lot more here than I take. So you can get off my back.
July 13, 2004, 7:46 PM
OnlyMeat
[quote author=Myndfyre link=board=17;threadid=7654;start=15#msg70201 date=1089741779]
[quote author=OnlyMeat link=board=17;threadid=7654;start=0#msg70130 date=1089692452]
Seems no one on here knows how to do it//or wants to share their knowledge so ill try and hunt down some c++ source for it instead.
[/quote]

Yes! Don't try to figure it out for yourself! Instead, copy someone else's work!
[/quote]

Well actually searching for some source code is my last resort only, i write all my code in c++ without any help usually so it's not as if im leeching off everyone thx!!

I write all my bots/programs based on my own packet analysis and not on the back of other peoples work i detest this the only reason i came on here in the first place was because i tried every avenue of testing//trial to get the code working ( I say code working but actually it's a sequence protocol//problem really ) and i thought maybe someone on here has had a similar problem and could give me a point in the right direction.

I certainly wont bother in the future if this is the kind of response i get.

ps. btw i was'nt trying to be sarcastic.
July 13, 2004, 9:52 PM
kamakazie
[quote author=OnlyMeat link=board=17;threadid=7654;start=15#msg70237 date=1089755540]
I certainly wont bother in the future if this is the kind of response i get.
[/quote]

Please don't be discouraged to post. It's always nice to have some new faces around here that have some idea of what they're trying to accomplish.

[me=dxoigmn]reminisces of the olds days on gamersx.com (now gamers.com)[/me]
July 13, 2004, 11:06 PM
OnlyMeat
Just a note to say i figured out the problem it was down to my connection code which by default connects asynchronously, although this worked fine for the realm and bnchat servers the game servers must be not be registered with any dns servers and consequently the resolved information being returned from async dns lookup WSAXX functions was incorrect and led to the faillure.

Thx for the ideas and responses it got me thinking and helped out.
July 14, 2004, 5:18 AM

Search