a month ago
I hava a API that has an andpoint where I submit two files, on localhost works on PROD (google cloud) works but on railway the connection just dies
does not give an error log, nothing
just give a 200 with the first line returned with yield
curl command by swagger:
curl -X 'POST' \ 'https://bez-stat-api-dev.up.railway.app/api/v1/analysis/objectives/ai-stream' \
-H 'accept: application/json' \
-H 'Authorization: TOKEN' \
-H 'Content-Type: multipart/form-data' \
-F 'database=@bd.xlsx;type=application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' \
-F 'objectives=@objetivos.pdf;type=application/pdf'
RESPONSE:
https://bez-stat-api-dev.up.railway.app/api/v1/analysis/objectives/ai-stream
Request Method
POST
Status Code
200 OK
yield "[DATA] info: Iniciando análise...\n\n"
Pinned Solution
a month ago
I resolved using flask_sse but IDK why it does not work with stream_with_context function
17 Replies
a month ago
This thread has been marked as public for community involvement, as it does not contain any sensitive or personal information. Any further activity in this thread will be visible to everyone.
Status changed to Open Railway • about 1 month ago
a month ago
I'm able to POST to the URL just fine. I'm not too sure what the issue exactly is, considering you mentioned that the connection dies.
$ curl -X POST https://bez-stat-api-dev.up.railway.app/api/v1/analysis/objectives/ai-stream
{"message": "Token n\u00e3o fornecido"}0x5b62656e5d
I'm able to POST to the URL just fine. I'm not too sure what the issue exactly is, considering you mentioned that the connection dies. ``` $ curl -X POST https://bez-stat-api-dev.up.railway.app/api/v1/analysis/objectives/ai-stream {"message": "Token n\u00e3o fornecido"} ```
a month ago
curl -X 'POST' \ 'https://bez-stat-api-dev.up.railway.app/api/v1/analysis/objectives/ai-stream' \
-H 'accept: application/json' \
-H 'Authorization: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyX2lkIjoiNjljYzdmNzYxZDFkOTlhNmQ2NDZlYWE2IiwiZXhwIjoxODA4MjcxMDMyfQ.8xz4WZaIIEkJ13UaE976AnUWJuybeYTSSPXtPyxrHz8' \
-H 'Content-Type: multipart/form-data' \
-F 'database=@bd.xlsx;type=application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' \
-F 'objectives=@objetivos.pdf;type=application/pdf'
fenol64
curl -X 'POST' \\ '<https://bez-stat-api-dev.up.railway.app/api/v1/analysis/objectives/ai-stream>' \\ \-H 'accept: application/json' \\ \-H 'Authorization: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyX2lkIjoiNjljYzdmNzYxZDFkOTlhNmQ2NDZlYWE2IiwiZXhwIjoxODA4MjcxMDMyfQ.8xz4WZaIIEkJ13UaE976AnUWJuybeYTSSPXtPyxrHz8' \\ \-H 'Content-Type: multipart/form-data' \\ \-F 'database=@bd.xlsx;type=application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' \\ \-F 'objectives=@objetivos.pdf;type=application/pdf'
a month ago
emulated token for you to test it
fenol64
emulated token for you to test it
a month ago
the database needs to be a .xlsx or csv file and the objectives is a pdf
fenol64
the database needs to be a .xlsx or csv file and the objectives is a pdf
a month ago
the URL is OK, but when it starts the streaming the connection dies and just returns the first line returned
my api is in python so I have a function that use 'yield' as return
yield "[DATA] info: Iniciando análise...\n\n"
yield "[DATA] A\n\n"
yield "[DATA] bn\n"
it just returns the first one yield "[DATA] info: Iniciando análise...\n\n" and the connection dies
a month ago
this is how im using
return Response(
stream_with_context(self.generate_ai_objectives_stream()),
mimetype='text/event-stream',
headers={
'Cache-Control': 'no-cache',
'Connection': 'keep-alive',
'X-Accel-Buffering': 'no'
}
)a month ago
You need to yield data: instead of [DATA].
For example:
yield "data: Some text stream"a month ago
You can also reference this:
0x5b62656e5d
You can also reference this: <https://utilities-us-east.up.railway.app/sse>
a month ago
I edited my code but does not work
same thing:
data: Iniciando análise...
fenol64
I edited my code but does not work same thing: data: Iniciando análise...
a month ago
it looks like the connection is just not keeping alive
a month ago
tcp
35.232.42.139:27017
10.217.122.222:56450
Internet
5.5 KB
34ms
NO_SOCKET
just found this log on 'Network Flow Logs'
a month ago
I'd try putting print/log statements before/after each yield so you can debug where your code (possibly) crashed in deployment logs.
a month ago
a month ago
i dont think this is a code error, i think its more a keep the connection to the client
a month ago
Sorry but not sure how to go about this one.
Railway's SSE sample works perfectly fine. (https://utilities-us-east.up.railway.app/sse)
a month ago
u have the repo?
a month ago
I resolved using flask_sse but IDK why it does not work with stream_with_context function
Status changed to Solved brody • about 1 month ago
