[SOLVED] wiz550io client fails to connect to http

#1

SOLVED

The problem was in how i created my shared network on my laptop, i deleted it and created it again and that fixed the issue. also i had fragmentation enabled, after disabling that i now get ‘error 400 bad request’ from the server which is a much better problem to have :slight_smile: thanks guys for your replies

[quote]
Hi,
I have my module working successfully as a server, but now i need to open another port and connect to a specific IP as an http client.
If I set destination port as 21 the CONNECT result is successful (0x17) and I can see the ACK from the server on Wireshark, however when I set the destination port as 80 there’s no ACK from the server and eventually I get a timeout error.
I can post code if required, (haven’t got it on me right now), however someone with more TCP/IP experience than myself might already be aware of issues and enlighten me. i.e. do I need to change something in the header? and if so what?

Please advice

EDIT
I should mention the server is definitely listening on port 80, as it is an http server, also I have made a telnet connection to it on port 80 with no problems, also I had disabled my firewall while testing.[/quote]

#2

Hi,

As my expeirence, Client conectinon some problems are two - wrong Destination IP and usage the same source port of SOCKET for client.

check the destination ip.
check the source port number. (not server(destination) port)

Thank you.

#3

Thanks midnightcow I appreciate your reply :slight_smile:
I’m not sure I understand though, if it were a port being re-used why would chance have it that it always fails when I attempt to connect to port 80?

I’m not attempting to open both ports on the same piece of code, rather, I compiled my code with port 21 hardcoded, then recompiled and cycled the power with port 80 hardcoded in. And always, it is port 80 that I fail to connect to…

#4

here’s my code, sorry i should have included earlier

void wiz550io_hit_server(void) {
switch(hit) {
case 0: // idle
break;
case 1:
spi_send_short(0x0010, 0x2C, 80); // dest PORT 80
spi_send_ip(0x000C, 0x2C, 101, 98, 9, 49); // dest ip
spi_send_ip(0x0001, 0x04, 192,168,1,5); // gateway
spi_send_ip(0x0005, 0x04, 255, 255, 255, 0); // mask
spi_send_short(0x0004, 0x2C, 13742);
spi_send_short(0x0012, 0x2C, 1024);
spi_send_char(0x0000, 0x2C, 0x01); // TCP mode

		spi_send_char(0x0001, 0x2C, 0x01); // OPEN
		ver = 0xFF;
		spi_trans_char(0x0003, 0x28, &ver);
		if(ver == 0x13) hit = 2;		// correct response to OPEN
		break;
	case 2:
		spi_send_char(0x0001, 0x2C, 0x04);	// CONNECT
		hit = 3;
		break;
	case 3:
		hit = 3;
		ver = 0xFF;
		spi_trans_char(0x0003, 0x28, &ver);
		if(ver == 0x17) hit = 4;		// correct response to CONNECT
		break;
	case 4:
		PORTA |= 0x01;
		o_add = 0xFFFF;
		spi_trans_short(0x0024, 0x28, &o_add);			// read start address
		spi_send_short(0x0022, 0x2C, o_add);			// write it to start index

		o_len = spi_trans_file(o_add, 0x34, hit_server);	// transfer page to tx buffer
		o_add += o_len;
		spi_send_short(0x0024, 0x2C, o_add);			// update end address
		spi_send_char(0x0001, 0x2C, 0x20);			// send it!!
		hit = 5;
		break;
	case 5:
		ver = 0xFF;
		spi_trans_char(0x0002, 0x28, &ver);
		hit = 5;
		if(ver & 0x10) hit = 6;				// all done? or error?
		if(ver & 0x02) hit = 6;
		break;
	case 6:
		//PORTA |= 0x01;
		spi_send_char(0x0001, 0x2C, 0x08);			// end connection
		hit = 0;
		break;
}

}

#5

Server application could hold before port number although before connection is closed(e.g. windows).
If that, Server application doesn’t accept re-connection with same port(combination of source and destination port number) number.

If you want to connect with same destination port number, I recommend to change source port number and open.

#6

ok, i see that’s what midnightcow was saying as well, thanks
i’ll test that out and upload my results

:slight_smile:

#7

still no luck,
i’ve modified the code to loop through port numbers and left it running all night.
here’s the new code
//
#define SP 49292

void wiz550io_hit_server(void) {
switch(hit) {
case 0: // idle
break;
case 1:
spi_send_short(0x0010, 0x2C, 80); // dest PORT 80
spi_send_ip(0x000C, 0x2C, 10,1,1,1); // dest ip
spi_send_ip(0x0001, 0x04, 10, 1, 1, 1); // gateway // was 192.168.1.5
spi_send_ip(0x0005, 0x04, 255, 255, 255, 0); // mask
spi_send_short(0x0004, 0x2C, my_port);
spi_send_short(0x0012, 0x2C, 1024);

		spi_send_char(0x001b, 0x04, 1);			// num retry	
		spi_send_short(0x0019, 0x04, 0xFF00);			// timeout		

		spi_send_char(0x0000, 0x2C, 0x01);	// TCP mode
					
		spi_send_char(0x0001, 0x2C, 0x01); // OPEN
		ver = 0xFF;
		spi_trans_char(0x0003, 0x28, &ver);
		if(ver == 0x13) hit = 2;		// correct response to OPEN
		break;
	case 2:
		spi_send_char(0x0001, 0x2C, 0x04);	// CONNECT
		hit = 3;
		break;
	case 3:
		hit = 3;
		ver = 0xFF;
		spi_trans_char(0x0003, 0x28, &ver);
		if(ver == 0x17) hit = 4;		// correct response to CONNECT
		if(ver == 0x00) hit = 7;
		break;
	case 4:
		PORTA |= 0x01;
		o_add = 0xFFFF;
		spi_trans_short(0x0024, 0x28, &o_add);			// read start address
		spi_send_short(0x0022, 0x2C, o_add);			// write it to start index

		o_len = spi_trans_file(o_add, 0x34, hit_server);	// transfer page to tx buffer
		o_add += o_len;
		spi_send_short(0x0024, 0x2C, o_add);			// update end address
		spi_send_char(0x0001, 0x2C, 0x20);			// send it!!
		hit = 5;
		break;
	case 5:
		ver = 0xFF;
		spi_trans_char(0x0002, 0x28, &ver);
		hit = 5;
		if(ver & 0x10) hit = 6;				// all done? or error?
		if(ver & 0x02) hit = 6;
		break;
	case 6:
		//PORTA |= 0x01;
		spi_send_char(0x0001, 0x2C, 0x08);			// end connection
		hit = 0;
		break;
	case 7:
		++my_port;
		if(my_port == 0) my_port = SP;
		hit = 1;	// try again
		break;
}

}
//

please if there’s nothing wrong with the code is it a problem with my setup? I have the module connected to my laptop’s ethernet port, i enabled ‘share my internet connection’ on the laptop, on the module the gateway ip is my laptop’s ip address. that wasn’t working so i tried connecting the module directly to the router ‘10.1.1.1’ and try to access the routers config page on port 80…
please any sugestions welcome

#8

Hi,

I was found the wrong code when controlling command regsiter.

You should check the clear of command after command register is written.

for example code

spi_send_char(0x0001, 0x2C, 0x01); // OPEN
ver = 0xFF;
while(ver != 0x00)
{
   spi_trans_char(0x0001, 0x2C, &ver);
}   

Thank you.

#9

Cheers for that :slight_smile:
I have since re-written the code and tidied up some bits, but I’ll check at home tonight that I didn’t carry that mistake across!

Thanks