Skip to content

Timeout error on handshake #4

@evershade

Description

@evershade

I've been trying to connect to my JVC LX-NZ30 projector via Home Assistant which seems to use this module. Was getting a generic connection message so I traced down to here and tried to run this module directly form Python on my Home Assistant server.

Here's my test code, based on your example:

import asyncio

from jvcprojector.projector import JvcProjector
from jvcprojector import const

async def main():
    jp = JvcProjector(host="192.168.1.19", port=4661, timeout=2)
    await jp.connect()

    print("Projector info:")
    print(await jp.get_info())

    await jp.disconnect()

asyncio.run(main())

Here's the error output I get:

Traceback (most recent call last):
  File "/usr/lib/python3.11/asyncio/tasks.py", line 490, in wait_for
    return fut.result()
           ^^^^^^^^^^^^
  File "/usr/lib/python3.11/asyncio/streams.py", line 689, in read
    await self._wait_for_data('read')
  File "/usr/lib/python3.11/asyncio/streams.py", line 522, in _wait_for_data
    await self._waiter
asyncio.exceptions.CancelledError

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/local/lib/python3.11/dist-packages/jvcprojector/device.py", line 117, in _connect
    data = await self._conn.read(len(PJOK))
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/dist-packages/jvcprojector/connection.py", line 50, in read
    return await asyncio.wait_for(self._reader.read(n), timeout=self._timeout)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/asyncio/tasks.py", line 492, in wait_for
    raise exceptions.TimeoutError() from exc
TimeoutError

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/homeassistant/jvc_get_info.py", line 15, in <module>
    asyncio.run(main())
  File "/usr/lib/python3.11/asyncio/runners.py", line 190, in run
    return runner.run(main)
           ^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/asyncio/runners.py", line 118, in run
    return self._loop.run_until_complete(task)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/asyncio/base_events.py", line 653, in run_until_complete
    return future.result()
           ^^^^^^^^^^^^^^^
  File "/homeassistant/jvc_get_info.py", line 8, in main
    await jp.connect()
  File "/usr/local/lib/python3.11/dist-packages/jvcprojector/projector.py", line 90, in connect
    if not await self.test():
           ^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/dist-packages/jvcprojector/projector.py", line 152, in test
    await self._send([cmd])
  File "/usr/local/lib/python3.11/dist-packages/jvcprojector/projector.py", line 180, in _send
    await self._device.send(cmds)
  File "/usr/local/lib/python3.11/dist-packages/jvcprojector/device.py", line 73, in send
    await self._connect()
  File "/usr/local/lib/python3.11/dist-packages/jvcprojector/device.py", line 119, in _connect
    raise JvcProjectorConnectError("Handshake init timeout") from err
jvcprojector.error.JvcProjectorConnectError: Handshake init timeout

It seems to be failing waiting on a handshake response. I've seen other mention of this handshake protocol on the web but the LX-NZ30 doesn't seem to require/support it. I've managed to successfully control my projector with as little as this:

import socket
import binascii

host = '192.168.1.19'
port = 4661

ctrl_power_on = b'\x06\x14\x00\x04\x00\x34\x11\x00\x00\x5D'

s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.send(ctrl_power_on)

received_data = s.recv(1024)
print (binascii.hexlify(received_data))

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions