---
title: "Using w7500 http client on W5100 gives bad requests"
url: "https://maker.wiznet.io/forum/12534"
markdown_url: "https://maker.wiznet.io/forum/12534/md"
type: "Forum topic"
category: "Ethernet Chips"
author: "ToasTer86"
created: "2017-10-27T08:40:46+09:00"
last_activity: "2017-10-29T23:15:46+09:00"
language: "en"
views: 1771
replies: 18
source: "WIZnet Makers forum (https://maker.wiznet.io/forum/)"
---

# Using w7500 http client on W5100 gives bad requests

## Question

Asked by ToasTer86 on 2017-10-27 in Ethernet Chips.

Hi Wiznet forum,

So I posted on [How to use http client with W5100 - #3 by mngz](https://forum.wiznet.io/t/topic/3251/3) & [HTTP post & get examples - #2 by irina_kim](https://forum.wiznet.io/t/topic/3716/2).
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:](https://emoji.discourse-cdn.com/twitter/slight_smile.png?v=12)

[![image](https://maker.wiznet.io/forum_uploads/wiznet/original/2X/d/d84d52910f453719d0f7f31f82e1cfbfef56febb.png) image958×936 48.1 KB](https://maker.wiznet.io/forum_uploads/wiznet/original/2X/d/d84d52910f453719d0f7f31f82e1cfbfef56febb.png)

## Replies

### Reply 1 by Eugeny, 2017-10-27

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.

### Reply 2 by ToasTer86, 2017-10-27 (in reply to reply 1)

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

[![image](https://maker.wiznet.io/forum_uploads/wiznet/original/2X/8/8bed44b41897e6c0292bad491185b1c4cdd2813f.png) image948×540 24.9 KB](https://maker.wiznet.io/forum_uploads/wiznet/original/2X/8/8bed44b41897e6c0292bad491185b1c4cdd2813f.png)

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.

### Reply 3 by Eugeny, 2017-10-27

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?

### Reply 4 by ToasTer86, 2017-10-27

Any idea where I should start looking ?

### Reply 5 by Eugeny, 2017-10-27

![](https://avatars.discourse-cdn.com/v4/letter/t/df705f/48.png) ToasTer86:

> 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.

### Reply 6 by ToasTer86, 2017-10-27

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

But I cant read what is in it.

[![image](https://maker.wiznet.io/forum_uploads/wiznet/original/2X/e/ebbdba8c30be500d95f22258d2d1d97d2ded4a24.png) image1920×1040 40.4 KB](https://maker.wiznet.io/forum_uploads/wiznet/original/2X/e/ebbdba8c30be500d95f22258d2d1d97d2ded4a24.png)

### Reply 7 by ToasTer86, 2017-10-27

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…

### Reply 8 by ToasTer86, 2017-10-27

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.

### Reply 9 by Eugeny, 2017-10-27

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?

### Reply 10 by ToasTer86, 2017-10-27

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: [BLE_to_TCP_W5500_Shield/examples/ble_central/ble_uart_c_to_tcpc/Wiznet at master · hooni1020/BLE_to_TCP_W5500_Shield · 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

### Reply 11 by ToasTer86, 2017-10-27

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 ?

### Reply 12 by ToasTer86, 2017-10-27

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

[![image](https://maker.wiznet.io/forum_uploads/wiznet/original/2X/0/0daf30578fa765478a8c5b82a90540b31f91d4d5.png) image1183×341 25.5 KB](https://maker.wiznet.io/forum_uploads/wiznet/original/2X/0/0daf30578fa765478a8c5b82a90540b31f91d4d5.png)

So it really seems that my current embedded board is not using the w5100 correctly at this moment ![:frowning:](https://emoji.discourse-cdn.com/twitter/frowning.png?v=12)

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

### Reply 13 by Eugeny, 2017-10-27

![](https://avatars.discourse-cdn.com/v4/letter/t/df705f/48.png) ToasTer86:

> what I actually should see is just the header

You posted [pic](https://maker.wiznet.io/forum/legacyFile.asp?path=uRuNne1AWTv3j7X4bw7yTFPA9bZ.png) with info you must see in the packet - in the black window text starting with “GET /device…”

![](https://avatars.discourse-cdn.com/v4/letter/t/df705f/48.png) ToasTer86:

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

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.

![](https://avatars.discourse-cdn.com/v4/letter/t/df705f/48.png) ToasTer86:

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

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

### Reply 14 by ToasTer86, 2017-10-27

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 - #4 by ToasTer86](https://forum.wiznet.io/t/topic/3251/4) 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.

### Reply 15 by ToasTer86, 2017-10-27

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);

### Reply 16 by ToasTer86, 2017-10-27

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

[![image](https://maker.wiznet.io/forum_uploads/wiznet/original/2X/b/b124f9ecd8d50f9e283585cb82f58abb75e20b9f.png) image1696×576 63.2 KB](https://maker.wiznet.io/forum_uploads/wiznet/original/2X/b/b124f9ecd8d50f9e283585cb82f58abb75e20b9f.png)

### Reply 17 by Eugeny, 2017-10-27

![](https://avatars.discourse-cdn.com/v4/letter/t/df705f/48.png) ToasTer86:

> It should have 4 sockets available right ?

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.

### Reply 18 by irina, 2017-10-29

Hi, Mark.

![](https://avatars.discourse-cdn.com/v4/letter/t/df705f/48.png) ToasTer86:

> 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 ?

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

---

Source: https://maker.wiznet.io/forum/12534
