R
Railway•2w ago
oz

Connection closed while reading from the driver

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"}%
curl -X POST "xxxxxxxxxx" \
-H "Content-Type: application/json" \
-d '{"url": "xxxxxxx
{"detail":"Connection closed while reading from the driver"}%
Code attached
36 Replies
Percy
Percy•2w ago
Project ID: 77fedaf9-b72c-45fa-b96e-6c1f7f459653
oz
oz•2w ago
77fedaf9-b72c-45fa-b96e-6c1f7f459653
Brody
Brody•2w ago
you can check your HTTP logs for more information
oz
oz•2w 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)
/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)
Is the only way to solve this is to use my systemw ith docker?
Brody
Brody•2w ago
you mean write your own dockerfile?
oz
oz•2w ago
Yeah Dont see how else I can add this dependency
Brody
Brody•2w 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?
oz
oz•2w 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
Brody
Brody•2w ago
sounds good! 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!
oz
oz•2w ago
So I use something similar, I use BrightData's bypass browser Much better overall experience and cheaper
Brody
Brody•2w ago
ah perfect, i just saw playwright and thought chrome install, my bad
oz
oz•2w ago
I seem to have got it all working though thanks!
Brody
Brody•2w ago
with a Dockerfile? that was fast
oz
oz•2w ago
I used perplexity tbh haha
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"]
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"]
Brody
Brody•2w ago
not ideal, you are using BrightData yet you are installing chrome now you are also installing python from apt-get, thats not a super stable install path for installing programming languages
Want results from more Discord servers?
Add your server