# Is it possible to keep session variables when a websocket is unexpectedly closed

**URL:** <https://forum.inductiveautomation.com/t/is-it-possible-to-keep-session-variables-when-a-websocket-is-unexpectedly-closed/106957>\
**Category:** Ignition\
**Tags:** ignition81, perspective\
**Created:** [June 3, 2025, 2:20pm UTC](https://forum.inductiveautomation.com/t/is-it-possible-to-keep-session-variables-when-a-websocket-is-unexpectedly-closed/106957 "2025-06-03T14:20:55Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![bmeyers](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bmeyers/32/37453_2.png) [@bmeyers](https://forum.inductiveautomation.com/u/bmeyers)\
**Post date:** [June 3, 2025, 2:20pm UTC](https://forum.inductiveautomation.com/t/is-it-possible-to-keep-session-variables-when-a-websocket-is-unexpectedly-closed/106957/1 "2025-06-03T14:20:55Z")

</div>

I have a customer who is super security conscious. One of their many firewalls is unexpectedly closing the websockets for their Perspective sessions.

Is it possible to keep session variables when this happens? The entire session is getting reset when this happens.

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [June 3, 2025, 2:23pm UTC](https://forum.inductiveautomation.com/t/is-it-possible-to-keep-session-variables-when-a-websocket-is-unexpectedly-closed/106957/2 "2025-06-03T14:23:36Z")

</div>

> [@bmeyers](#):
>
> The entire session is getting reset when this happens.

This shouldn't be happening, as the session is established with ephemeral cookies in the client browser. Breaking the websocket should recover without losing the session.

Something more than just websocket breakage is happening. (Load balancer sending to a different front-end, perhaps?)

---

<div class="post-metadata">

**Author:** ![bmeyers](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bmeyers/32/37453_2.png) [@bmeyers](https://forum.inductiveautomation.com/u/bmeyers)\
**Post date:** [June 3, 2025, 2:27pm UTC](https://forum.inductiveautomation.com/t/is-it-possible-to-keep-session-variables-when-a-websocket-is-unexpectedly-closed/106957/3 "2025-06-03T14:27:54Z")

</div>

![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/6/9/6996b0069df1b64957d0c64e963d53ec9074c345.png)

This is what appears in the logs when it happens (randomly every 10-15 minutes)

The Ignition Gateway is hosted in AWS and I am VPN into their plant floor so many places for something to go wrong. If it is just my client then it won't be a problem but I assumed it was all clients (rolling out to production soon).

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [June 3, 2025, 2:54pm UTC](https://forum.inductiveautomation.com/t/is-it-possible-to-keep-session-variables-when-a-websocket-is-unexpectedly-closed/106957/4 "2025-06-03T14:54:12Z")

</div>

Hmm. Looks like something the firewall deliberately injected, instead of just cutting off.

---

<div class="post-metadata">

**Author:** ![bmeyers](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bmeyers/32/37453_2.png) [@bmeyers](https://forum.inductiveautomation.com/u/bmeyers)\
**Post date:** [June 3, 2025, 8:47pm UTC](https://forum.inductiveautomation.com/t/is-it-possible-to-keep-session-variables-when-a-websocket-is-unexpectedly-closed/106957/5 "2025-06-03T20:47:43Z")

</div>

After further investigation I opened a client in Chrome instead of Firefox and this problem didn't occur anymore. I then re-installed Firefox after not being able to identify what setting was causing the problem and the initial problem went away.

So this was a client-side problem caused by unknown settings in Firefox.

---

<div class="post-metadata">

**Author:** ![nminchin](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nminchin/32/6911_2.png) [@nminchin](https://forum.inductiveautomation.com/u/nminchin)\
**Post date:** [June 3, 2025, 10:15pm UTC](https://forum.inductiveautomation.com/t/is-it-possible-to-keep-session-variables-when-a-websocket-is-unexpectedly-closed/106957/6 "2025-06-03T22:15:14Z")

</div>

Fwiw, I've seen other strange things with Firefox like rendering abnormalities, where both edge and Chrome are fine 🤷 I never use Firefox because of this

---

<div class="post-metadata">

**Author:** ![bmeyers](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bmeyers/32/37453_2.png) [@bmeyers](https://forum.inductiveautomation.com/u/bmeyers)\
**Post date:** [June 4, 2025, 3:17pm UTC](https://forum.inductiveautomation.com/t/is-it-possible-to-keep-session-variables-when-a-websocket-is-unexpectedly-closed/106957/7 "2025-06-04T15:17:22Z")

</div>

A new issue appeared and I figured I'd just keep this forum thread alive instead of opening a new one since it is the same end-result for me (Ignition 8.1.47 Perspective).

Periodically the following request URL is sent and everything works fine. The session doesn't get reset.

```python
http://digitalfactory.customername.com:8088/data/perspective/keepalive/CNCMachines/31ec32e1/4390683237901289
```

But once in a while the following request URL gets sent.

```python
http://digitalfactory.customername.com:8088/data/perspective/hello/CNCMachines/31ec32e1
```

And the second request URL appears to be causing a refresh of the project.

Does anyone know what the **/data/perspective/hello** is about?

This is what the initiator looks like.

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/0/9/0920a594978c883e1bafc5469eb12c444b3325fa.png)

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [June 4, 2025, 3:41pm UTC](https://forum.inductiveautomation.com/t/is-it-possible-to-keep-session-variables-when-a-websocket-is-unexpectedly-closed/106957/8 "2025-06-04T15:41:39Z")

</div>

The `hello` route is part of session initialization - I suspect it's a symptom, as in once that's happening whatever is breaking has already broken.

---

<div class="post-metadata">

**Author:** ![bmeyers](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bmeyers/32/37453_2.png) [@bmeyers](https://forum.inductiveautomation.com/u/bmeyers)\
**Post date:** [June 4, 2025, 10:13pm UTC](https://forum.inductiveautomation.com/t/is-it-possible-to-keep-session-variables-when-a-websocket-is-unexpectedly-closed/106957/9 "2025-06-04T22:13:29Z")

</div>

I went and swapped my session variables to memory tags to overcome this particular issue for this particular customer instead of spending several days trying to debug what is happening.

---

<div class="post-metadata">

**Author:** ![nminchin](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nminchin/32/6911_2.png) [@nminchin](https://forum.inductiveautomation.com/u/nminchin)\
**Post date:** [June 5, 2025, 1:25am UTC](https://forum.inductiveautomation.com/t/is-it-possible-to-keep-session-variables-when-a-websocket-is-unexpectedly-closed/106957/10 "2025-06-05T01:25:00Z")

</div>

> [@bmeyers](#):
>
> swapped my session variables to memory tags

err, these work in completely different ways though: session props are session-scoped (a set for each session), tags are gateway-scoped (one set for everything). You were either incorrectly using sessions props to begin with, or you've messed it up now for individual sessions (unless you're using datasets with rows per session, sets of memory tags per session dynamically created, or something similar)

---

<div class="post-metadata">

**Author:** ![Leor\_Fishman](https://avatars.discourse-cdn.com/v4/letter/l/e19adc/32.png) [@Leor\_Fishman](https://forum.inductiveautomation.com/u/Leor_Fishman)\
**Post date:** [June 5, 2025, 1:38am UTC](https://forum.inductiveautomation.com/t/is-it-possible-to-keep-session-variables-when-a-websocket-is-unexpectedly-closed/106957/11 "2025-06-05T01:38:19Z")

</div>

now i've become a bit nerdsniped wondering how you'd best simulate session props with memory tags....probably a user-model UDT with per user ID instancing?

---

<div class="post-metadata">

**Author:** ![nminchin](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nminchin/32/6911_2.png) [@nminchin](https://forum.inductiveautomation.com/u/nminchin)\
**Post date:** [June 5, 2025, 1:39am UTC](https://forum.inductiveautomation.com/t/is-it-possible-to-keep-session-variables-when-a-websocket-is-unexpectedly-closed/106957/12 "2025-06-05T01:39:07Z")

</div>

You wouldn't, you would just use session props 😛  
But yes, that's probably what I would do. Per-user or per-session, I guess it depends what your aim is. Probably use the Perspective session startup event to initialise it all.

This might be one way to maintain user preferences across sessions?

---

<div class="post-metadata">

**Author:** ![Leor\_Fishman](https://avatars.discourse-cdn.com/v4/letter/l/e19adc/32.png) [@Leor\_Fishman](https://forum.inductiveautomation.com/u/Leor_Fishman)\
**Post date:** [June 5, 2025, 1:39am UTC](https://forum.inductiveautomation.com/t/is-it-possible-to-keep-session-variables-when-a-websocket-is-unexpectedly-closed/106957/13 "2025-06-05T01:39:44Z")

</div>

well, unless you wanted to historize them

---

<div class="post-metadata">

**Author:** ![bmeyers](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bmeyers/32/37453_2.png) [@bmeyers](https://forum.inductiveautomation.com/u/bmeyers)\
**Post date:** [June 5, 2025, 3:10am UTC](https://forum.inductiveautomation.com/t/is-it-possible-to-keep-session-variables-when-a-websocket-is-unexpectedly-closed/106957/14 "2025-06-05T03:10:08Z")

</div>

> [@nminchin](#):
>
> You were either incorrectly using sessions props to begin with

Yes, this is true but it doesn't explain what is resetting my sessions. Anyways, there were too many variables and no time to go through them all.
