# Ability to set order if websocket disconnects

**URL:** <https://community.tradovate.com/t/ability-to-set-order-if-websocket-disconnects/4663>\
**Category:** API Developers\
**Created:** [May 19, 2022, 11:59am UTC](https://community.tradovate.com/t/ability-to-set-order-if-websocket-disconnects/4663 "2022-05-19T11:59:21Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![beebee](https://sea1.discourse-cdn.com/flex015/user_avatar/community.tradovate.com/beebee/32/1776_2.png) [@beebee](https://community.tradovate.com/u/beebee)\
**Post date:** [May 19, 2022, 11:59am UTC](https://community.tradovate.com/t/ability-to-set-order-if-websocket-disconnects/4663/1 "2022-05-19T11:59:21Z")

</div>

Is it possible to say if I am in an open order and the websocket connection disconnects, that the current open order is closed or ability to set a resting order in the order book?

---

<div class="post-metadata">

**Author:** ![Alexander](https://sea1.discourse-cdn.com/flex015/user_avatar/community.tradovate.com/alexander/32/988_2.png) [@Alexander](https://community.tradovate.com/u/Alexander)\
**Post date:** [May 19, 2022, 3:57pm UTC](https://community.tradovate.com/t/ability-to-set-order-if-websocket-disconnects/4663/2 "2022-05-19T15:57:39Z")

</div>

You could try to make HTTP calls to close your positions on the `onclose` websocket hook, given you have a valid access token at the time of disconnect.

---

<div class="post-metadata">

**Author:** ![beebee](https://sea1.discourse-cdn.com/flex015/user_avatar/community.tradovate.com/beebee/32/1776_2.png) [@beebee](https://community.tradovate.com/u/beebee)\
**Post date:** [May 19, 2022, 6:41pm UTC](https://community.tradovate.com/t/ability-to-set-order-if-websocket-disconnects/4663/3 "2022-05-19T18:41:23Z")

</div>

When I login through a browser that counts as 1 connection, so does the API using a websocket. If I log out of the browser, it still shows that I am connected to multiple devices.

Can I force drop all connections, not unlink but say disconnect connections?

---

<div class="post-metadata">

**Author:** ![Alexander](https://sea1.discourse-cdn.com/flex015/user_avatar/community.tradovate.com/alexander/32/988_2.png) [@Alexander](https://community.tradovate.com/u/Alexander)\
**Post date:** [May 19, 2022, 7:22pm UTC](https://community.tradovate.com/t/ability-to-set-order-if-websocket-disconnects/4663/4 "2022-05-19T19:22:56Z")

</div>

The server drops connections by timestamp, the oldest connection is always the one that is dropped if a new connection is authorized.

---

<div class="post-metadata">

**Author:** ![beebee](https://sea1.discourse-cdn.com/flex015/user_avatar/community.tradovate.com/beebee/32/1776_2.png) [@beebee](https://community.tradovate.com/u/beebee)\
**Post date:** [May 19, 2022, 8:24pm UTC](https://community.tradovate.com/t/ability-to-set-order-if-websocket-disconnects/4663/5 "2022-05-19T20:24:06Z")

</div>

There might be a bug in this timestamping code.

Here’s how I can reproduce the issue.

I have an open websocket connection, login to the browser. Logout of the browser; while the websocket connection is still enabled.

The browser will prompt you to choose to close the oldest session, logout or another option.

no matter which option I choose, after this, the websocket can no longer successfully connect. It keeps replying with 429 error.

I can login to the browser session; live, replay or simulation but the websocket connection no longer works.

I can consistently reproduce this issue because it keeps killing my api connections.

---

<div class="post-metadata">

**Author:** ![beebee](https://sea1.discourse-cdn.com/flex015/user_avatar/community.tradovate.com/beebee/32/1776_2.png) [@beebee](https://community.tradovate.com/u/beebee)\
**Post date:** [May 20, 2022, 11:42am UTC](https://community.tradovate.com/t/ability-to-set-order-if-websocket-disconnects/4663/6 "2022-05-20T11:42:30Z")

</div>

Once i get the on close message the websocket is already stale, i’ll have to figure out another way to solve this problem.
