"Attempting to reauthenticate; Websocket reconnected" loop
I'm seeing this (see screenshot) in the dev console, in production only. I'm also only seeing this when logged in.
Any idea what might be causing this?

9 Replies
This happens when the client is configured correctly, but the server is not. Have you deployed to prod after running
convex auth add
?I have, but I'm seeing that the issuer is different between dev and prod, so I suppose that's probably the issue? How should I handle that with Convex?
convex auth add
both?
convex auth add
ing the prod issuer did solve the problem, but it seems a bit odd that both dev/prod issuer domains be present in both dev/prod environments. I imagine that makes it easier than it would be otherwise to accidentally configure dev auth in prod (or the inverse). Maybe something like convex auth add --prod
and convex auth add --dev
(with some corresponding delineation in convex.json
's authInfo
field) would be nice to have?Nice, and to understand the issue fully, you configured your Publishable key to be different between prod and dev in
ClerkProvider
?I did, yes
Yeah I think you're spot on. You can change
convex.json
to have one provider, and convex dev
/convex deploy
to the correct deployment. This is a bit wonky and we're working on simplifying the deployments story.Do you mean change
convex.json
on the fly, pre-deployment? Or have two convex.json
or something? I want both auth providers, just a different one in each environment (dev vs prod).@RJ you can change convex.json (via
convex auth add
or manually), then run convex deploy
to change the prod configuration. Then you can revert the changes and run convex dev
with the previous configuration. If you're deploying to prod from Vercel or another hosting platform you would need to make sure that the convex.json is also changed in that environment.
We're working on making this flow easier in the future.
The other thing you might consider is to use the same Publishable key for both dev and prod to avoid this additional complexity.Isn't that equivalent to using the same users in prod and dev? Clerk seems to want you to use a different publishable key in each environment, also--they present a different one for each env.
But either way, the ability to specify different
authInfo
configs in each env would solve my problem!Depending on how exactly you’re leveraging Clerk, using the same set of users in prod and dev might not be so bad. You can test authentication via test emails. I think the main reason Clerk provides the distinction is to enable quick development via their oath credentials in dev.
Hey @RJ , wanted to let you know that we released Convex 0.12.4 with several Auth fixes. It doesn't help with the situation we discussed here directly, but it will throw a clearer error instead of running the reauthenticate->reconnected loop. Try it out and let us know how it goes!