Connection closed while reading from the driver
ozeitis
PROOP

2 years ago

Hey so my code works fine (code below) locally but in Railway hosted I am getting the below error, anyway I can fix this?

Essentially I am using playwright to scrape some data and return it via the python API

curl -X POST "xxxxxxxxxx" \
     -H "Content-Type: application/json" \
     -d '{"url": "xxxxxxx
{"detail":"Connection closed while reading from the driver"}%```


Code attached

48 Replies

ozeitis
PROOP

2 years ago

77fedaf9-b72c-45fa-b96e-6c1f7f459653


2 years ago

you can check your HTTP logs for more information


ozeitis
PROOP

2 years ago

/opt/venv/lib/python3.9/site-packages/playwright/driver/node: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.36' not found (required by /nix/store/xpxln7rqi3pq4m0xpnawhxb2gs0mn1s0-gcc-12.3.0-lib/lib/libstdc++.so.6)


ozeitis
PROOP

2 years ago

Is the only way to solve this is to use my systemw ith docker?


2 years ago

you mean write your own dockerfile?


ozeitis
PROOP

2 years ago

Yeah


ozeitis
PROOP

2 years ago

Dont see how else I can add this dependency


2 years ago

its complicated for the most part, i'd recommend moving to a dockerfile, i can give your Dockerfile a once over after you write it?


ozeitis
PROOP

2 years ago

Appreciate it, never really used docker tbh, I should learn it at some point. WIll build one and send it if I run into issue sthanks


2 years ago

sounds good!


2 years ago

additionally, would you be interested in using browserless? not having to install and bundle chrome into your container would decrease the build time, and also decrease the publish times!


ozeitis
PROOP

2 years ago

So I use something similar, I use BrightData's bypass browser


ozeitis
PROOP

2 years ago

Much better overall experience


ozeitis
PROOP

2 years ago

and cheaper


2 years ago

ah perfect, i just saw playwright and thought chrome install, my bad


ozeitis
PROOP

2 years ago

I seem to have got it all working though thanks!


2 years ago

with a Dockerfile? that was fast


ozeitis
PROOP

2 years ago

I used perplexity tbh haha


ozeitis
PROOP

2 years ago

FROM mcr.microsoft.com/playwright:v1.38.0-focal

# Install Python and pip
RUN apt-get update && apt-get install -y python3 python3-pip

# Set the working directory
WORKDIR /app

# Copy the requirements file
COPY requirements.txt .

# Install the Python dependencies
RUN pip3 install --no-cache-dir -r requirements.txt

# Copy the rest of the application code
COPY . .

# Install Playwright browsers and dependencies
RUN playwright install chromium
RUN playwright install-deps

# Set the command to run the application
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8080"]

2 years ago

not ideal, you are using BrightData yet you are installing chrome now


2 years ago

you are also installing python from apt-get, thats not a super stable install path for installing programming languages


ozeitis
PROOP

2 years ago

Ah your right, stupid of me to confuse that. I wonder if I am not using brightdata correctly which prompted the need for this


2 years ago

well first off, simply try removing those two playwright commands


ozeitis
PROOP

2 years ago

Yes your right .. it still worked 🙂


2 years ago

okay now instead of FROM playwright and then installing python with apt-get, you can do FROM python with a version


ozeitis
PROOP

2 years ago

Hey sorry will check thatbut quick question


ozeitis
PROOP

2 years ago

{"detail":"BrowserType.connect_over_cdp: WebSocket error: wss://xxxxxxxx@brd.superproxy.io:9222/ 401 Auth Failed (ip_blacklisted: 34.105.6.0/24)\nAuth Failed ip_blacklisted: 34.105.6.0/24\nCall log:\n wss://xxxxxxxx@brd.superproxy.io:9222/\n  -  wss://xxxxxxxx@brd.superproxy.io:9222/ 401 Auth Failed (ip_blacklisted: 34.105.6.0/24)\nAuth Failed ip_blacklisted: 34.105.6.0/24\n  -  wss://xxxxxxxx@brd.superproxy.io:9222/ error WebSocket was closed before the connection was established\n  -  wss://xxxxxxxx@brd.superproxy.io:9222/ WebSocket was closed before the connection was established\n  -  wss://xxxxxxxx@brd.superproxy.io:9222/ code=1006 reason=\n"}%  ```


ozeitis
PROOP

2 years ago

Is this saying BrightData blacklisted you guys?


ozeitis
PROOP

2 years ago

Or the other way arround?


ozeitis
PROOP

2 years ago

Every request was working at first


2 years ago

very possible, but its also a 401 instead of 403, so maybe your credentials are wrong / expired?


ozeitis
PROOP

2 years ago

Cant be, working locally fine


2 years ago

Gotcha, do you have static Ips enabled?


ozeitis
PROOP

2 years ago

Apologies for my lack of experience in this.

On Railway or BrightData?


2 years ago

on your railway service, check the service settings


ozeitis
PROOP

2 years ago

Disabled


ozeitis
PROOP

2 years ago

Static Outbound IPs


2 years ago

try enabling that


ozeitis
PROOP

2 years ago

I did but they get banned fast it seems


2 years ago

ah then you would need to get in contact with them


ozeitis
PROOP

2 years ago

So its them blocking you? (BrightData)


2 years ago

correct


ozeitis
PROOP

2 years ago

Thanks for info Brody. Any info I can provide that will help them? Like any info about yoru servr or IP ranges or etc?


2 years ago

you have a static IP now, so that's all you'd need to give them


ozeitis
PROOP

2 years ago

Perfect thanks again. I always feel confident in my knowledge until I run into these issues then remeber I have so muc more to learn 🙂 Appreciate your pateince with me.


2 years ago

I wish I could help here but unfortunately an IP ban is outside of what we can control


ozeitis
PROOP

2 years ago

Of course I understand


ozeitis
PROOP

2 years ago

You helped a lot already


Welcome!

Sign in to your Railway account to join the conversation.

Loading...