mpetazzoni / sseclient

Pure-Python Server Side Events (SSE) client
Apache License 2.0
186 stars 33 forks source link

SSEClient fails to connect #32

Closed houmie closed 5 months ago

houmie commented 5 months ago

I have followed your example with requests:

url = "https://xxx-5000.proxy.runpod.net/v1/completions"
stream_response = requests.post(
    url, headers=headers, json=data, verify=False, stream=True
)
client = sseclient.SSEClient(stream_response)

The first line with requests.post() works fine, but the SSEClient() on the last line fails with this error: requests.exceptions.InvalidURL: Failed to parse: <Response [200]>

Maybe I need to do this instead: client = sseclient.SSEClient(stream_response.url)

This now throws a different error: requests.exceptions.HTTPError: 405 Client Error: Method Not Allowed for url: https://xxx-5000.proxy.runpod.net/v1/completions

Any idea what the issue could be please? Thanks

mpetazzoni commented 5 months ago

You definitely want to pass the stream_response object to SSEClient's constructor, not the URL.

This may be because of an invalid (invisible) character in your URL. Can you try by tying the URL value manually, instead of copy-pasting it? Alternatively, it may be because of an incompatibility between your version of requests and your version of urllib3.

Shoelace commented 5 months ago

my first guess is you've imported teh wrong sseclient.

pip install sseclient IS WRONG you need pip install sseclient-py

note the -py part

try this.. to check what library you have installed (if your on windows and cant grep.. just scan teh output for the correct value)

$ pip list |grep sse
sseclient-py                       1.7