The issue tends to happen at random intervals regardless of the method I use to create the session. My best luck has been with tokens lasting the longest, but the session is inevitably terminated. I do not receive any specific error, and it appears to be at random. Currently, I am using llib3 and HTTPAdapter in Python to connect and its been the most stable.
It seems like you're experiencing intermittent issues with session termination. Here are some potential solutions and things to look out for:
Token Expiration: According to the documentation, session tokens have a lifetime of one minute. You may need to fetch new session tokens using Shopify App Bridge for each request to ensure stale tokens aren't used.
Error Handling: Make sure you have appropriate error handling in place. This can help you catch and log exceptions, which can provide insights if the sessions are failing due to specific errors.
Concurrency Issues: If your application is handling multiple requests concurrently, make sure that your session handling is thread-safe.
Server Time Sync: Ensure that your server time is synced. JWT token verification can fail if your server's time is significantly ahead or behind.
Network Issues: Intermittent network issues can also cause random session termination.
Session Storage: If you're storing session information in a database or some other storage, ensure that the storage system is working correctly and efficiently.
If you've checked all these and the issue persists, let us know and we'll look into this specific case further.