# HTTP Sessions in REST API

**URL:** <https://forum.bondhome.io/t/http-sessions-in-rest-api/1868>\
**Category:** Integrations\
**Created:** [September 23, 2020, 12:58am UTC](https://forum.bondhome.io/t/http-sessions-in-rest-api/1868 "2020-09-23T00:58:38Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![kingwr](https://avatars.discourse-cdn.com/v4/letter/k/ecc23a/32.png) [@kingwr](https://forum.bondhome.io/u/kingwr)\
**Post date:** [September 23, 2020, 12:58am UTC](https://forum.bondhome.io/t/http-sessions-in-rest-api/1868/1 "2020-09-23T00:58:38Z")

</div>

Testing the BPUP in my ISY/Polyglot integration, I notice something (I think) new: every call to the REST appears to use a new connection despite the fact that I am using sessions in Python requests. I.e., in each call I see “Resetting dropped connection: zzbl48XXX.local”. Are sessions not something I need to be using in the REST API? Does the Bond Bridge drop the connection after each HTTP call?

---

<div class="post-metadata">

**Author:** ![kingwr](https://avatars.discourse-cdn.com/v4/letter/k/ecc23a/32.png) [@kingwr](https://forum.bondhome.io/u/kingwr)\
**Post date:** [September 23, 2020, 1:01am UTC](https://forum.bondhome.io/t/http-sessions-in-rest-api/1868/2 "2020-09-23T01:01:35Z")

</div>

Note that I did just upgrade 2.14.5 firmware. It could be that as well. Did persistent connections get dropped in the latest firmware?

---

<div class="post-metadata">

**Author:** ![kingwr](https://avatars.discourse-cdn.com/v4/letter/k/ecc23a/32.png) [@kingwr](https://forum.bondhome.io/u/kingwr)\
**Post date:** [September 24, 2020, 12:36am UTC](https://forum.bondhome.io/t/http-sessions-in-rest-api/1868/3 "2020-09-24T00:36:14Z")

</div>

@residualimages Any insight here?

---

<div class="post-metadata">

**Author:** ![residualimages](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.bondhome.io/residualimages/32/74_2.png) [@residualimages](https://forum.bondhome.io/u/residualimages)\
**Post date:** [September 24, 2020, 12:42am UTC](https://forum.bondhome.io/t/http-sessions-in-rest-api/1868/4 "2020-09-24T00:42:43Z")

</div>

@kingwr - sorry, I haven’t had time to dig into BPUP / the Polyglot nodeserver for awhile (healthcare IT as a day job - you can imagine how #2020 is going).

Technically I even paused the Polyglot Bond nodeserver usage (😟) since there are a few things I’m able to work out quicker with direct Network Resources (mostly the Patch using \_m:4 for State correcting, and cross integrating with Hue emulator nodeserver for Harmony control).

Hoping @jacob, @merck or one of the other Bond team members have a chance to wander in this week.

---

<div class="post-metadata">

**Author:** ![kingwr](https://avatars.discourse-cdn.com/v4/letter/k/ecc23a/32.png) [@kingwr](https://forum.bondhome.io/u/kingwr)\
**Post date:** [September 24, 2020, 1:03am UTC](https://forum.bondhome.io/t/http-sessions-in-rest-api/1868/5 "2020-09-24T01:03:43Z")

</div>

While it may appear so from the original post, note that this question doesn’t have anything to do with BPUP. I just happened to notice that my REST calls were receiving this warning (the resetting of the connection) when I was testing the updated integration with the BPUP code. The integration has used HTTP sessions from the beginning, but I don’t remember seeing this warning. Doesn’t mean it hasn’t been there all along.

---

<div class="post-metadata">

**Author:** ![jacob](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.bondhome.io/jacob/32/312_2.png) [@jacob](https://forum.bondhome.io/u/jacob)\
**Post date:** [September 24, 2020, 4:54pm UTC](https://forum.bondhome.io/t/http-sessions-in-rest-api/1868/6 "2020-09-24T16:54:03Z")

</div>

> [@kingwr](#):
>
> Doesn’t mean it hasn’t been there all along.

It’s likely that it’s been there all along: the Bond’s HTTP server closes the client socket after it sends the response content. This should be what’s causing the dropped connection.

---

<div class="post-metadata">

**Author:** ![kingwr](https://avatars.discourse-cdn.com/v4/letter/k/ecc23a/32.png) [@kingwr](https://forum.bondhome.io/u/kingwr)\
**Post date:** [September 25, 2020, 1:54pm UTC](https://forum.bondhome.io/t/http-sessions-in-rest-api/1868/7 "2020-09-25T13:54:29Z")

</div>

I went back through the old logs, and I wasn’t seeing the connection reset error with the old version of the integration, even after the firmware upgrade. Turns out that these errors are going to root logger and get lost in the Polyglot infrastructure. They only show up in debugging the code in VSC. I removed all the HTTP session code.

BTW, BPUP works great - a nice improvement over 10s polling.

---

<div class="post-metadata">

**Author:** ![merck](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.bondhome.io/merck/32/1238_2.png) [@merck](https://forum.bondhome.io/u/merck)\
**Post date:** [October 1, 2020, 5:19pm UTC](https://forum.bondhome.io/t/http-sessions-in-rest-api/1868/8 "2020-10-01T17:19:06Z")

</div>

> [@kingwr](#):
>
> BTW, BPUP works great - a nice improvement over 10s polling.

🎊

We love the BPUP over here. Curious: are you acting as a client to subscribe to BPUP messages? Or are you just listening to the broadcasts?

---

<div class="post-metadata">

**Author:** ![kingwr](https://avatars.discourse-cdn.com/v4/letter/k/ecc23a/32.png) [@kingwr](https://forum.bondhome.io/u/kingwr)\
**Post date:** [October 2, 2020, 10:56pm UTC](https://forum.bondhome.io/t/http-sessions-in-rest-api/1868/10 "2020-10-02T22:56:15Z")

</div>

@merck I wasn’t aware there were broadcasts. I am opening a UDP socket connection to the bridge on port 30007 and sending the keep-alive datagram every 90 seconds (or so).

---

<div class="post-metadata">

**Author:** ![merck](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.bondhome.io/merck/32/1238_2.png) [@merck](https://forum.bondhome.io/u/merck)\
**Post date:** [October 7, 2020, 2:26pm UTC](https://forum.bondhome.io/t/http-sessions-in-rest-api/1868/11 "2020-10-07T14:26:48Z")

</div>

There is a broadcast option, but you need to enable it via the API. (We felt it was not right to broadcast by default.)

Docs link for it:  
[http://docs-local.appbond.com/#tag/BPUP/paths/~1v2~1api~1bpup/patch](http://docs-local.appbond.com/#tag/BPUP/paths/~1v2~1api~1bpup/patch)

---

<div class="post-metadata">

**Author:** ![kingwr](https://avatars.discourse-cdn.com/v4/letter/k/ecc23a/32.png) [@kingwr](https://forum.bondhome.io/u/kingwr)\
**Post date:** [October 7, 2020, 6:06pm UTC](https://forum.bondhome.io/t/http-sessions-in-rest-api/1868/12 "2020-10-07T18:06:17Z")

</div>

So not really a UDP broadcast in the strictest sense of the word, but more of a removal of the need for the keep-alive datagram?

Basically make the same UDP connection to port 30007 and then make a REST call to enable the BPUP “broadcast.” and you’re done. No loop for keep-alive. Is there any other advantages/disadvantages?

---

<div class="post-metadata">

**Author:** ![merck](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.bondhome.io/merck/32/1238_2.png) [@merck](https://forum.bondhome.io/u/merck)\
**Post date:** [October 23, 2020, 12:23am UTC](https://forum.bondhome.io/t/http-sessions-in-rest-api/1868/13 "2020-10-23T00:23:14Z")

</div>

> So not really a UDP broadcast

No, it’s really a broadcast.

If you enable BPUP broadcast, as I described above, Bond will transmit a UDP packet to 255.255.255.255:30007 for every single state change. So, you just need to listen locally to port 30007 (without binding to the first client!) and you will pick up state changes from every Bond on the subnet!

---

<div class="post-metadata">

**Author:** ![kingwr](https://avatars.discourse-cdn.com/v4/letter/k/ecc23a/32.png) [@kingwr](https://forum.bondhome.io/u/kingwr)\
**Post date:** [October 23, 2020, 1:39am UTC](https://forum.bondhome.io/t/http-sessions-in-rest-api/1868/14 "2020-10-23T01:39:12Z")

</div>

Oh, OK. I will give it a try in the next version.
