import pymongo, os, multiprocessing
from pymongo import errors
from urllib import request
from http import server
# minimal server for if your code isn't already serving a website before you connect to mongodb
class Server(server.BaseHTTPRequestHandler):
# Do this to override the log_request function to prevent spammy logging output
def log_request(_, __):
pass
def do_HEAD(self):
self.send_response(204)
self.end_headers()
do_GET = do_HEAD
multiprocessing.Process(
target=server.ThreadingHTTPServer(("", 80), Server).serve_forever
).start()
try:
# connect to mongo here, e.g.
client = pymongo.MongoClient(
f"mongodb+srv://admin:{os.environ['db-password']}@cluster0.1shpg.mongodb.net/myFirstDatabase?retryWrites=true&w=majority"
)
except errors.ServerSelectionTimeoutError:
request.urlopen(f"https://{os.environ['REPL_ID']}.id.repl.co")
os.kill(1, 1)
Iām now getting mongodb errors again (node.js), with Internal Server Error and Unknown system error -122. Looks like this issue wasnāt fully fixed and a timeframe on when this could be resolved would be great.
I donāt think itās an issue on Replitās side. I donāt know for certain, but my theory is that one of Replitās IPs is blacklisted from Mongo as itās only an issue sometimes and kill 1 sometimes helps.
I apologize for our sparse updates! We are still coordinating with our upstream providers to find the cause. I have prompted the Replit team for an update and will revert here once I get a reply.
This Problem is A deal Breaker The Server Is Unable To Connect To the Database And itās causing a lot of down time (till now mostly down time) please an urgent fix is required
Weāre looking into this now that it has come up again, and we are able to reproduce it. We are getting in touch with an upstream service to coordinate the resolution of this issue.
I only get this error on some of my repls. kill 1 usually fixes it temporarily, but after a while the error occurs again. It looks like replit has problems with websocket connections at the moment.
Please fix these issues, they are causing a lot of downtime.
How much egress have you used? I remember that kind of issue when my account was over the egress limit (back when each free user only had 1gb of egress).