WIZnet Developer Forum

Using w7500 http client on W5100 gives bad requests

Hi Wiznet forum,

So I posted on How to use http client with W5100 & HTTP post & get examples.
Although I thought making a new topic might increase the visibility on the issue.

In the first topic someone rewritten the W7500 http client to the W5100, i have done so as well. but right now I am not able to send out valid requests, and the data I receive is in a weird format.

In the image below in the putty terminal you can see the header I am sending out over the W5100.
And in the wireshark behind you can see the bad request & and the message I receive.
The message I receive is also encoded so I cant really read it.

any help would be appreciated, I am trying to get this working :slight_smile:

If it replies with bad request, then you make bad request to the server. Where’s screenshot of the request packet? Please attach it to see what your W5100 requests from server.

Well that is the funny thing I only see one HTTP in wireshark and that is the bad request:

So the DHCP is the start up from the machine. The wiznet chip gets IP 192.168.137.151.
Then establishes a connection to 104.31.86.204 (https://requestb.in/)
But I do not see a outgoing HTTP request.

I think the library I am using has to be re written for the wiznet 5100 chip but I am not sure where.

Message #16 must be a request to server. As Wireshark does not classify it as HTTP, your driver is really sending something incorrectly. What is the content of this packet?

Any idea where I should start looking ?

You should open packet #16 in wireshark, look at its data content yourself, and show it here so that we can also see what is in.

Hey , I have opend the packet, thanks so much for your help so far.

But I cant read what is in it.

if I copy the text as bytes I get the following :

ScEn@XhVPk;uPe|’?f(A/:($N_C4;G4xc!X4F>@2w3

or

0000 9c eb e8 53 63 06 00 08 dc 00 ab cd 08 00 45 00 …Sc…E.
0010 00 6e 00 06 40 00 80 06 f1 58 c0 a8 89 97 68 1f .n…@…X…h.
0020 56 cc cb cd 00 50 6b 3b 75 df 97 97 0e cf 50 18 V…Pk;u…P.
0030 10 00 8b 89 00 00 b2 65 c8 a8 be 7c c5 e8 00 27 …e…|…'
0040 0d 0b 94 f1 ed 91 bf 3f 66 28 41 d9 2f 3a 9d 28 …?f(A./:.(
0050 fb 24 ef 4e 5f c0 1e 00 b5 8d 43 34 3b f8 47 06 .$.N_…C4;.G.
0060 d6 34 ff b3 f1 1a f0 15 f4 78 84 63 ad 21 58 34 .4…x.c.!X4
0070 07 46 93 b9 3e 40 32 d2 9b 77 33 9a .F…>@2…

Packet export through wireshark

No. Time Source Destination Protocol Length Info
14 0.680129 192.168.137.151 104.31.86.204 TCP 124 52173 → 80 [PSH, ACK] Seq=1 Ack=1 Win=4096 Len=70

Frame 14: 124 bytes on wire (992 bits), 124 bytes captured (992 bits) on interface 0
Ethernet II, Src: Wiznet_00:ab:cd (00:08:dc:00:ab:cd), Dst: BizlinkK_53:63:06 (9c:eb:e8:53:63:06)
Internet Protocol Version 4, Src: 192.168.137.151, Dst: 104.31.86.204
Transmission Control Protocol, Src Port: 52173, Dst Port: 80, Seq: 1, Ack: 1, Len: 70
Source Port: 52173
Destination Port: 80
[Stream index: 1]
[TCP Segment Len: 70]
Sequence number: 1 (relative sequence number)
[Next sequence number: 71 (relative sequence number)]
Acknowledgment number: 1 (relative ack number)
0101 … = Header Length: 20 bytes (5)
Flags: 0x018 (PSH, ACK)
Window size value: 4096
[Calculated window size: 4096]
[Window size scaling factor: -2 (no window scaling used)]
Checksum: 0x8b89 [unverified]
[Checksum Status: Unverified]
Urgent pointer: 0
[SEQ/ACK analysis]
[iRTT: 0.006675000 seconds]
[Bytes in flight: 70]
[Bytes sent since last PSH flag: 70]
TCP payload (70 bytes)

Thanks again for all the help and pointers.

And what you think web server should respond for this request? Of course it responds with 400 bad request. You must now debug why W5100 sends this garbage instead of HTTP request you construct earlier. Do you copy the required data into TX buffer? Do you use correct pointers - memory and TX buffer?

Requestb.in should respond with a text format " Ok "

I will have to check about tx and the points, I am just using the httpClient.C library and the library for the wiznet chips as proposed on this github: https://github.com/hooni1020/BLE_to_TCP_W5500_Shield/tree/master/examples/ble_central/ble_uart_c_to_tcpc/Wiznet

I changed the SPI pins and the SPI mode to 0 and was able to iniatilize ethernet and a IP adress.
Also got DHCP working. I am using the user_ethernet.c & user_spi.c to write .

So I have not changed anything in w5100.c / wizchip_conf.h

Eugeny , so with the " garbage’" you mean that what I actually should see is just the header and post I am sending on the chip ?

Those weird signs and data is a sign that my chip is not functioning correctly ?

If I use the wiznet 5100 with the arduino and the HTTP client I get immediatly good connection and package

ScEF@s$Pt=G{PIcGET /search?q=arduino HTTP/1.1

So it really seems that my current embedded board is not using the w5100 correctly at this moment :frowning:

I really thought I had it working cause I do have DHCP & DNS being correctly setup.

You posted pic with info you must see in the packet - in the black window text starting with “GET /device…”

No, it most probably means that your driver (your code accessing W5100) does not handle W5100 correctly, I do not think it is hardware issue.

These use UDP, but you are trying using TCP. These may be different parts of the code.

Yeah I will have to troubleshoot this now and see where I am going wrong.

In this post How to use http client with W5100 eric says I will have to edit the socket functions to use his library. Seems I have to figure out what mngz did to make it work.

Thanks again for your help, if you have any suggestions of where I should look I would appreciate it.

Well woooow, I just fixed it.

I was opening socket 3 on the wiznet 5100. Now I changed it to socket 1 and it immediatly works.
How could this be the problem. It should have 4 sockets available right ?

prototype of the function :
uint8_t httpc_init(uint8_t sock, uint8_t * ip, uint16_t port, uint8_t * sbuf, uint8_t * rbuf);

call of the function httpc_init(3, back_end_ip, 80, g_send_buf, g_recv_buf);

changed it to

httpc_init(1, back_end_ip, 80, g_send_buf, g_recv_buf);

Screenshot of a succesfull GET on httpbin calling an IP address.

Yes, it should have worked through socket 3. Search for problems in the code. Assuming you have 2K RAM allocation for each socket (0x55 in both memory registers), and according to your finding, I think it could be the case what you were writing data to the wrong socket TX location.

Hi, Mark.

Is socket 3 already in use by another task, or is it possible that the socket was set to over 2kB in the initialization of the socket buffer?

The default value of TX and RX socket buffer size is 2KB each. For a W5100 chip with four hardware sockets, If you adjust the TX / RX buffer size of ‘socket 0’ to 4KB(x 2), the buffer size of ‘socket 3’ becomes 0 (Not available).

I hope you find the cause of the problem.

Regards,
Eric

Copyright © 2017 WIZnet Co., Ltd. All Rights Reserved.