Skip to content

WebSocket Connection Timeout Error During Image Generation - Previously Working, Now Consistently Failing #141

@naquoc

Description

@naquoc

I'm experiencing a WebSocket connection timeout error when using the Runware SDK for image generation. This functionality was working properly before, but has been consistently failing for this week. The error occurs during the initial connection handshake.

Error Details:

CancelledError                            Traceback (most recent call last)
File ~/Code/one_more_line/.conda/lib/python3.12/site-packages/websockets/asyncio/client.py:541, in connect.__await_impl__(self)
    540 for _ in range(MAX_REDIRECTS):
--> 541     self.connection = await self.create_connection()
    542     try:

File ~/Code/one_more_line/.conda/lib/python3.12/site-packages/websockets/asyncio/client.py:467, in connect.create_connection(self)
    466     # Initialize WebSocket connection.
--> 467     _, connection = await loop.create_connection(factory, **kwargs)
    468 return connection

File ~/Code/one_more_line/.conda/lib/python3.12/asyncio/base_events.py:1107, in BaseEventLoop.create_connection(self, protocol_factory, host, port, ssl, family, proto, flags, sock, local_addr, server_hostname, ssl_handshake_timeout, ssl_shutdown_timeout, happy_eyeballs_delay, interleave, all_errors)
   1106 try:
-> 1107     sock = await self._connect_sock(
   1108         exceptions, addrinfo, laddr_infos)
   1109     break

File ~/Code/one_more_line/.conda/lib/python3.12/site-packages/websockets/asyncio/client.py:651, in BaseSelectorEventLoop.sock_connect(self, sock, address)
    650 try:
...
    576 except TimeoutError as exc:
    577     # Re-raise exception with an informative error message.
--> 578     raise TimeoutError("timed out during opening handshake") from exc

TimeoutError: timed out during opening handshake

Code:

async def generating_images_with_runware(
    image_path: str,
    positivePrompt: str,
    negativePrompt: str,
    image_id: int,
    # ... other parameters
):
    runware = Runware(api_key=os.environ["RUNWARE_API_KEY"], timeout=120)
    await runware.connect()  # Error occurs here
    
    # ... rest of the function

Environment:

Python 3.12.9
macOS sequoia 15.5
Runware SDK (0.4.17)

Workaround:

Currently using the HTTP-based implementation as a workaround, but would prefer to use the official SDK for better integration and features.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions