Search code examples
webrtctokbox

tokbox Error creating session: Error: Failed to createSession


I created an application using tokbox, and suddenly, stop working and throw this error

I have restarted, my keys are fine ... I don't know what could have happened ..

Error creating session: Error: Failed to createSession. Error: An authentication error occurred: 
(403) {"code":-1,"message":"token has expired","description":"token has expired"}

Solution

  • This issue appears to be caused by a JSON Web Token expiration issue when there is a system/server clock synchronization misalignment.

    In our case, it appeared the developer was changing timezone settings on their machine and the system clocks got out of sync with the development server somehow (though the timezone was set to his local time at the moment).

    We initially solved this by changing the timezone in the Windows system settings. At this point the error went away without restarting the servers.

    When we changed the timezone back to the actual local timezone everything continued to work.

    UPDATE:

    The developer ran into the same issue again and timezone changing did not fix it this time. We realized that the Docker Container was being created with the wrong time settings (We determined this by logging out the current time in the container). The date in the docker container was a day and several hours behind the computer's time.

    It is important to note that deleting the images and restarting the containers alone did not solve the issue. Also, we found that other JWT tokens in the application were also affected not just opentok's.

    To solve this, we had to stop Docker Desktop and restart it. This resynchronized all newly created container times to the Windows machine time.

    See also: Tokbox failed to create session