# Multiple HTTP Requests - every other one fails

**URL:** <https://forum.sierrawireless.com/t/multiple-http-requests-every-other-one-fails/4184>\
**Category:** Open AT\
**Created:** [February 9, 2010, 4:16pm UTC](https://forum.sierrawireless.com/t/multiple-http-requests-every-other-one-fails/4184 "2010-02-09T16:16:46Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![awneil](https://avatars.discourse-cdn.com/v4/letter/a/49beb7/32.png) [@awneil](https://forum.sierrawireless.com/u/awneil)\
**Post date:** [February 9, 2010, 4:16pm UTC](https://forum.sierrawireless.com/t/multiple-http-requests-every-other-one-fails/4184/1 "2010-02-09T16:16:46Z")

</div>

OS: 6.21;  
WIP: 5.10;  
Firmware: R73a;

> [@Open AT® IP Connectivity Development Guide (WIPlib v5.10)](#):
>
> 9.17 The wip\_close Function
> 
> On a request channel, the wip\_close function closes the channel and makes the session ready for another request. When HTTP1.1 is used this does not close the TCP communication channel, it can be reused if the next request is sent to the same server.

But it doesn’t seem to work!

After making a GET or PUT request, I receive the CEV\_PEER\_CLOSE event, and call wip\_close to, “close the channel and make the session ready for another request” - as the guide says (see above).  
But the next request (GET or PUT) will always fail with CERR\_ABORTED, “channel closed by server”

After this failure, the next request (GET or PUT) will always work!

It looks like the wip\_close is not correctly making the channel ready for another request!

These are the traces at the end of a successful request, on the CEV\_PEER\_CLOSE event:

```auto
wip_close=0
[WIP] closing HTTP_DATA 0x180c43e4
[HTTP] destroy request @ 180c43e4
[WIPEV] WIP_CEV_PEER_CLOSE @ TCPCLIENT 0x180c4684
[req_event] WIP_CEV_PEER_CLOSE
```

In this case, note that only HTTP\_DATA is closed.

And these are the traces at the end of a failed request, on the CEV\_ERROR (CERR\_ABORTED) event:

```auto
wip_close=0
[WIP] closing TCPCLIENT 0x180c4684
[WIP] closing HTTP_DATA 0x180c4964
[HTTP] destroy request @ 180c4964
```

In this case, note that both HTTP\_DATA and TCPCLIENT are closed - and, after this, the next request will work.

The code is the Wavecom WIP HTTP GET sample from the SDK;  
The [WIP] and [WIPEV] and [HTTP] and [req\_event] are internal traces from WIP itself.

So, what’s going wrong here? Why is wip\_close not doing its job?

---

<div class="post-metadata">

**Author:** ![JasonDiplomat](https://avatars.discourse-cdn.com/v4/letter/j/71e660/32.png) [@JasonDiplomat](https://forum.sierrawireless.com/u/JasonDiplomat)\
**Post date:** [February 9, 2010, 4:43pm UTC](https://forum.sierrawireless.com/t/multiple-http-requests-every-other-one-fails/4184/2 "2010-02-09T16:43:34Z")

</div>

Do you need to give it time to “recover” after closing?

---

<div class="post-metadata">

**Author:** ![awneil](https://avatars.discourse-cdn.com/v4/letter/a/49beb7/32.png) [@awneil](https://forum.sierrawireless.com/u/awneil)\
**Post date:** [February 9, 2010, 5:01pm UTC](https://forum.sierrawireless.com/t/multiple-http-requests-every-other-one-fails/4184/3 "2010-02-09T17:01:31Z")

</div>

Even after 2.5 minutes it still fails!

---

<div class="post-metadata">

**Author:** ![awneil](https://avatars.discourse-cdn.com/v4/letter/a/49beb7/32.png) [@awneil](https://forum.sierrawireless.com/u/awneil)\
**Post date:** [February 10, 2010, 1:10pm UTC](https://forum.sierrawireless.com/t/multiple-http-requests-every-other-one-fails/4184/4 "2010-02-10T13:10:59Z")

</div>

I have just rebuilt exactly the same code with:  
Firmware 663 + Open-AT 4.20 + WIP 3.01

This works every time!  
(which explains why I was sure that I’d done this before and not had this problem).

So, it looks like something in WIP has been broken between v3.01 and v5.10… 😒

---

<div class="post-metadata">

**Author:** ![Madouc](https://avatars.discourse-cdn.com/v4/letter/m/b782af/32.png) [@Madouc](https://forum.sierrawireless.com/u/Madouc)\
**Post date:** [February 10, 2010, 3:40pm UTC](https://forum.sierrawireless.com/t/multiple-http-requests-every-other-one-fails/4184/5 "2010-02-10T15:40:15Z")

</div>

have you also tried with 5.20 ? (included with 7.4a)

---

<div class="post-metadata">

**Author:** ![awneil](https://avatars.discourse-cdn.com/v4/letter/a/49beb7/32.png) [@awneil](https://forum.sierrawireless.com/u/awneil)\
**Post date:** [February 10, 2010, 4:27pm UTC](https://forum.sierrawireless.com/t/multiple-http-requests-every-other-one-fails/4184/6 "2010-02-10T16:27:45Z")

</div>

No, I haven’t (yet).

The problem seems to be to do with the TCPCLIENT - which appears in the traces, but is not visible to the application (it is neither the application’s Data channel, nor the application’s Session channel)

The TCPCLIENT is entirely invisible to the application & hidden within WIP

The HTTP\_DATA in the traces is the application’s Data channel, and it can be seen that events on this are notified to the application’s Data channel event handler:

```auto
[WIPEV] WIP_CEV_PEER_CLOSE @ HTTP_DATA 0x180c44c4
Data Ch=180C44C4 Ev=3
http_ClientTestDataHandler: WIP_CEV_PEER_CLOSE
```

But the TCPCLIENT events are not notified to the application at all - particularly its PEER-CLOSE event:

```auto
[WIPEV] WIP_CEV_PEER_CLOSE @ TCPCLIENT 0x180c4744
[req_event] WIP_CEV_PEER_CLOSE
```

And it is this which causes the CERR\_ABORTED error when the application tried to make its next request.

WIP 3.01 handled this internally, and would automatically create a new TCPCLIENT if it needed to;

WIP 5.10 doesn’t do this automatically, and provides no way for the application to know that it needs to be done - it just fails the request! 😠

---

<div class="post-metadata">

**Author:** ![awneil](https://avatars.discourse-cdn.com/v4/letter/a/49beb7/32.png) [@awneil](https://forum.sierrawireless.com/u/awneil)\
**Post date:** [February 10, 2010, 4:46pm UTC](https://forum.sierrawireless.com/t/multiple-http-requests-every-other-one-fails/4184/7 "2010-02-10T16:46:50Z")

</div>

As a side note, these kind of traces are generated “internally” by WIP:

```auto
[WIP] closing HTTP_DATA 0x180c43e4
[HTTP] destroy request @ 180c43e4
[WIPEV] WIP_CEV_PEER_CLOSE @ TCPCLIENT 0x180c4684
[req_event] WIP_CEV_PEER_CLOSE
```

To enable them, you need to set the Log Events Flag:

```auto
wip_logEvents = TRUE; /* Enable all WIP Event traces */
```

You specify whether you want them to appear in the Trace, or on UART1 or on UART2 by using the appropriate option in wip\_netInitOpts:

```auto
r = wip_netInitOpts
( 
      //WIP_NET_OPT_DEBUG_PORT, WIP_NET_DEBUG_PORT_UART1, /* WIP traces on UART1 */
      //WIP_NET_OPT_DEBUG_PORT, WIP_NET_DEBUG_PORT_UART2,
        WIP_NET_OPT_DEBUG_PORT, WIP_NET_DEBUG_PORT_TRACE, /* WIP traces in TRACE */

      WIP_NET_OPT_END /* Marks the end of the options */
);
```

---

<div class="post-metadata">

**Author:** ![awneil](https://avatars.discourse-cdn.com/v4/letter/a/49beb7/32.png) [@awneil](https://forum.sierrawireless.com/u/awneil)\
**Post date:** [February 11, 2010, 6:24pm UTC](https://forum.sierrawireless.com/t/multiple-http-requests-every-other-one-fails/4184/8 "2010-02-11T18:24:36Z")

</div>

> [@awneil](#):
>
> WIP 5.10 doesn’t do this automatically, and provides no way for the application to know that it needs to be done

Even if it did know that it needed to be done, WIP provides nothing that would allow the application to correct the situation, other than closing the Session Channel - which the documentation specifically states should not be required!

I call this a bug: [WIP v5.10 Bug: Multiple HTTP Requests](https://forum.sierrawireless.com/t/wip-v5-10-bug-multiple-http-requests/4193/1)
