Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OSError: [Errno 65] No route to host #143

Open
bindiry opened this issue Feb 18, 2025 · 10 comments
Open

OSError: [Errno 65] No route to host #143

bindiry opened this issue Feb 18, 2025 · 10 comments

Comments

@bindiry
Copy link

bindiry commented Feb 18, 2025

I got this information hen i execute command alga tv add default 192.168.0.155 in terminal.

╭───────────────────── Traceback (most recent call last) ──────────────────────╮
│ /Users/user1/.local/pipx/venvs/alga/lib/python3.13/site-packages/alga/cli_tv. │
│ py:46 in add                                                                 │
│                                                                              │
│    43 │   │   │   )                                                          │
│    44 │   │   │   raise Exit(code=1)                                         │
│    45 │                                                                      │
│ ❱  46 │   with client.connect(hostname=hostname, timeout=60) as connection:  │
│    47 │   │   connection.send(json.dumps(get_hello_data()))                  │
│    48 │   │   response = json.loads(connection.recv())                       │
│    49 │   │   assert response == {                                           │
│                                                                              │
│ ╭────────── locals ──────────╮                                               │
│ │ hostname = '192.168.0.155' │                                               │
│ │       ip = '192.168.0.155' │                                               │
│ │     name = 'default'       │                                               │
│ ╰────────────────────────────╯                                               │
│                                                                              │
│ /opt/homebrew/Cellar/[email protected]/3.13.1/Frameworks/Python.framework/Versions │
│ /3.13/lib/python3.13/contextlib.py:141 in __enter__                          │
│                                                                              │
│   138 │   │   # they are only needed for recreation, which is not possible a │
│   139 │   │   del self.args, self.kwds, self.func                            │
│   140 │   │   try:                                                           │
│ ❱ 141 │   │   │   return next(self.gen)                                      │
│   142 │   │   except StopIteration:                                          │
│   143 │   │   │   raise RuntimeError("generator didn't yield") from None     │
│   144                                                                        │
│                                                                              │
│ ╭────────────────────────────── locals ──────────────────────────────╮       │
│ │ self = <contextlib._GeneratorContextManager object at 0x1020e1a90> │       │
│ ╰────────────────────────────────────────────────────────────────────╯       │
│                                                                              │
│ /Users/user1/.local/pipx/venvs/alga/lib/python3.13/site-packages/alga/client. │
│ py:18 in connect                                                             │
│                                                                              │
│   15 @contextmanager                                                         │
│   16 def connect(hostname: str, timeout: int = 10) -> Iterator[WebSocket]:   │
│   17 │   connection = WebSocket(sslopt={"cert_reqs": ssl.CERT_NONE})         │
│ ❱ 18 │   connection.connect(f"wss://{hostname}:3001/", suppress_origin=True, │
│   19 │                                                                       │
│   20 │   try:                                                                │
│   21 │   │   yield connection                                                │
│                                                                              │
│ ╭──────────────────────────── locals ────────────────────────────╮           │
│ │ connection = <websocket._core.WebSocket object at 0x1020cacf0> │           │
│ │   hostname = '192.168.0.155'                                   │           │
│ │    timeout = 60                                                │           │
│ ╰────────────────────────────────────────────────────────────────╯           │
│                                                                              │
│ /Users/user1/.local/pipx/venvs/alga/lib/python3.13/site-packages/websocket/_c │
│ ore.py:256 in connect                                                        │
│                                                                              │
│   253 │   │   │   Pre-initialized stream socket.                             │
│   254 │   │   """                                                            │
│   255 │   │   self.sock_opt.timeout = options.get("timeout", self.sock_opt.t │
│ ❱ 256 │   │   self.sock, addrs = connect(                                    │
│   257 │   │   │   url, self.sock_opt, proxy_info(**options), options.pop("so │
│   258 │   │   )                                                              │
│   259                                                                        │
│                                                                              │
│ ╭────────────────────────── locals ───────────────────────────╮              │
│ │ options = {'suppress_origin': True, 'timeout': 60}          │              │
│ │    self = <websocket._core.WebSocket object at 0x1020cacf0> │              │
│ │     url = 'wss://192.168.0.155:3001/'                       │              │
│ ╰─────────────────────────────────────────────────────────────╯              │
│                                                                              │
│ /Users/user1/.local/pipx/venvs/alga/lib/python3.13/site-packages/websocket/_h │
│ ttp.py:145 in connect                                                        │
│                                                                              │
│   142 │                                                                      │
│   143 │   sock = None                                                        │
│   144 │   try:                                                               │
│ ❱ 145 │   │   sock = _open_socket(addrinfo_list, options.sockopt, options.ti │
│   146 │   │   if need_tunnel:                                                │
│   147 │   │   │   sock = _tunnel(sock, hostname, port_from_url, auth)        │
│   148                                                                        │
│                                                                              │
│ ╭────────────────────────────── locals ──────────────────────────────╮       │
│ │ addrinfo_list = [                                                  │       │
│ │                 │   (                                              │       │
│ │                 │   │   <AddressFamily.AF_INET: 2>,                │       │
│ │                 │   │   <SocketKind.SOCK_STREAM: 1>,               │       │
│ │                 │   │   6,                                         │       │
│ │                 │   │   '',                                        │       │
│ │                 │   │   ('192.168.0.155', 3001)                    │       │
│ │                 │   )                                              │       │
│ │                 ]                                                  │       │
│ │          auth = None                                               │       │
│ │      hostname = '192.168.0.155'                                    │       │
│ │     is_secure = True                                               │       │
│ │   need_tunnel = False                                              │       │
│ │       options = <websocket._socket.sock_opt object at 0x1020cae40> │       │
│ │ port_from_url = 3001                                               │       │
│ │         proxy = <websocket._http.proxy_info object at 0x1020cb380> │       │
│ │      resource = '/'                                                │       │
│ │          sock = None                                               │       │
│ │        socket = None                                               │       │
│ │           url = 'wss://192.168.0.155:3001/'                        │       │
│ ╰────────────────────────────────────────────────────────────────────╯       │
│                                                                              │
│ /Users/user1/.local/pipx/venvs/alga/lib/python3.13/site-packages/websocket/_h │
│ ttp.py:222 in _open_socket                                                   │
│                                                                              │
│   219 │   │   │   │   except AttributeError:                                 │
│   220 │   │   │   │   │   eConnRefused = (errno.ECONNREFUSED, errno.ENETUNRE │
│   221 │   │   │   │   if error.errno not in eConnRefused:                    │
│ ❱ 222 │   │   │   │   │   raise error                                        │
│   223 │   │   │   │   err = error                                            │
│   224 │   │   │   │   continue                                               │
│   225 │   │   │   else:                                                      │
│                                                                              │
│ ╭───────────────────────────────── locals ─────────────────────────────────╮ │
│ │       address = ('192.168.0.155', 3001)                                  │ │
│ │      addrinfo = (                                                        │ │
│ │                 │   <AddressFamily.AF_INET: 2>,                          │ │
│ │                 │   <SocketKind.SOCK_STREAM: 1>,                         │ │
│ │                 │   6,                                                   │ │
│ │                 │   '',                                                  │ │
│ │                 │   ('192.168.0.155', 3001)                              │ │
│ │                 )                                                        │ │
│ │ addrinfo_list = [                                                        │ │
│ │                 │   (                                                    │ │
│ │                 │   │   <AddressFamily.AF_INET: 2>,                      │ │
│ │                 │   │   <SocketKind.SOCK_STREAM: 1>,                     │ │
│ │                 │   │   6,                                               │ │
│ │                 │   │   '',                                              │ │
│ │                 │   │   ('192.168.0.155', 3001)                          │ │
│ │                 │   )                                                    │ │
│ │                 ]                                                        │ │
│ │  eConnRefused = (61, 51)                                                 │ │
│ │           err = None                                                     │ │
│ │        family = <AddressFamily.AF_INET: 2>                               │ │
│ │          opts = (6, 258, 3)                                              │ │
│ │         proto = 6                                                        │ │
│ │          sock = <socket.socket [closed] fd=-1, family=2, type=1,         │ │
│ │                 proto=6>                                                 │ │
│ │       sockopt = []                                                       │ │
│ │      socktype = <SocketKind.SOCK_STREAM: 1>                              │ │
│ │       timeout = 60                                                       │ │
│ ╰──────────────────────────────────────────────────────────────────────────╯ │
│                                                                              │
│ /Users/user1/.local/pipx/venvs/alga/lib/python3.13/site-packages/websocket/_h │
│ ttp.py:209 in _open_socket                                                   │
│                                                                              │
│   206 │   │   err = None                                                     │
│   207 │   │   while not err:                                                 │
│   208 │   │   │   try:                                                       │
│ ❱ 209 │   │   │   │   sock.connect(address)                                  │
│   210 │   │   │   except socket.error as error:                              │
│   211 │   │   │   │   sock.close()                                           │
│   212 │   │   │   │   error.remote_ip = str(address[0])                      │
│                                                                              │
│ ╭───────────────────────────────── locals ─────────────────────────────────╮ │
│ │       address = ('192.168.0.155', 3001)                                  │ │
│ │      addrinfo = (                                                        │ │
│ │                 │   <AddressFamily.AF_INET: 2>,                          │ │
│ │                 │   <SocketKind.SOCK_STREAM: 1>,                         │ │
│ │                 │   6,                                                   │ │
│ │                 │   '',                                                  │ │
│ │                 │   ('192.168.0.155', 3001)                              │ │
│ │                 )                                                        │ │
│ │ addrinfo_list = [                                                        │ │
│ │                 │   (                                                    │ │
│ │                 │   │   <AddressFamily.AF_INET: 2>,                      │ │
│ │                 │   │   <SocketKind.SOCK_STREAM: 1>,                     │ │
│ │                 │   │   6,                                               │ │
│ │                 │   │   '',                                              │ │
│ │                 │   │   ('192.168.0.155', 3001)                          │ │
│ │                 │   )                                                    │ │
│ │                 ]                                                        │ │
│ │  eConnRefused = (61, 51)                                                 │ │
│ │           err = None                                                     │ │
│ │        family = <AddressFamily.AF_INET: 2>                               │ │
│ │          opts = (6, 258, 3)                                              │ │
│ │         proto = 6                                                        │ │
│ │          sock = <socket.socket [closed] fd=-1, family=2, type=1,         │ │
│ │                 proto=6>                                                 │ │
│ │       sockopt = []                                                       │ │
│ │      socktype = <SocketKind.SOCK_STREAM: 1>                              │ │
│ │       timeout = 60                                                       │ │
│ ╰──────────────────────────────────────────────────────────────────────────╯ │
╰──────────────────────────────────────────────────────────────────────────────╯

What should I do for this?
Thank you very much.

System: macOS 15.3.1
LG TV webos: 24 9.2.1 2608

@Tenzer
Copy link
Owner

Tenzer commented Feb 18, 2025

Hi!

"No route to host" is an error from the operating system, saying it cannot connect to the IP address you have provided. Are you sure it is correct? Does it for instance respond if you run ping 192.168.0.155?

@bindiry
Copy link
Author

bindiry commented Feb 18, 2025

Hi!

"No route to host" is an error from the operating system, saying it cannot connect to the IP address you have provided. Are you sure it is correct? Does it for instance respond if you run ping 192.168.0.155?

Thank you for reply.

Yes, I can receive respond from run ping 192.168.0.155.

❯ ping 192.168.0.155
PING 192.168.0.155 (192.168.0.155): 56 data bytes
64 bytes from 192.168.0.155: icmp_seq=0 ttl=64 time=36.635 ms
64 bytes from 192.168.0.155: icmp_seq=1 ttl=64 time=1.808 ms
64 bytes from 192.168.0.155: icmp_seq=2 ttl=64 time=1.896 ms
64 bytes from 192.168.0.155: icmp_seq=3 ttl=64 time=1.992 ms
64 bytes from 192.168.0.155: icmp_seq=4 ttl=64 time=2.353 ms
64 bytes from 192.168.0.155: icmp_seq=5 ttl=64 time=2.293 ms
64 bytes from 192.168.0.155: icmp_seq=6 ttl=64 time=1.817 ms
64 bytes from 192.168.0.155: icmp_seq=7 ttl=64 time=2.015 ms
^C
--- 192.168.0.155 ping statistics ---
8 packets transmitted, 8 packets received, 0.0% packet loss
round-trip min/avg/max/stddev = 1.808/6.351/36.635/11.448 ms

@bindiry
Copy link
Author

bindiry commented Feb 18, 2025

Could it be that alga needs to obtain Local Network permission to connect to the local network? I checked System Settings -> Privacy & Security -> Local Network list, and alga is not there.

The firewall is also turned off.

@Tenzer
Copy link
Owner

Tenzer commented Feb 18, 2025

Could it be that alga needs to obtain Local Network permission to connect to the local network? I checked System Settings -> Privacy & Security -> Local Network list, and alga is not there.

I don't believe so, it doesn't appear on the list on my machine and neither does Python for that matter.

It looks like you are on a Mac, so you should have nc (netcat) installed. You can try to see if it can connect to the port on the TV, just to make sure it works outside of Alga: nc -vz 192.168.0.155 3001.

It should ideally give something back like:

Connection to 192.168.0.155 port 3001 [tcp/redwood-broker] succeeded!

@bindiry
Copy link
Author

bindiry commented Feb 18, 2025

Could it be that alga needs to obtain Local Network permission to connect to the local network? I checked System Settings -> Privacy & Security -> Local Network list, and alga is not there.

I don't believe so, it doesn't appear on the list on my machine and neither does Python for that matter.

It looks like you are on a Mac, so you should have nc (netcat) installed. You can try to see if it can connect to the port on the TV, just to make sure it works outside of Alga: nc -vz 192.168.0.155 3001.

It should ideally give something back like:

Connection to 192.168.0.155 port 3001 [tcp/redwood-broker] succeeded!

Yes, I tried this command line and got the same respond:

❯ nc -vz 192.168.0.155 3001
Connection to 192.168.0.155 port 3001 [tcp/redwood-broker] succeeded!

@Tenzer
Copy link
Owner

Tenzer commented Feb 18, 2025

Odd! Are you able to retry the Alga command again, just to verify it still sees the issue even though the OS can connect?

@bindiry
Copy link
Author

bindiry commented Feb 18, 2025

Odd! Are you able to retry the Alga command again, just to verify it still sees the issue even though the OS can connect?

I just tried, It’s still the error message at the top.

Could it be that the TV actively refused my connection? I used to use an older version of alga, and when I initialized the connection with the TV, it would display an authorization prompt, but this time it didn’t.

@bindiry
Copy link
Author

bindiry commented Feb 18, 2025

Wow, it worked! I switched to using Terminal.app and it succeeded.

I was using iTerm.app before, so it seems to be an issue with iTerm.

Thank you very much.

@Tenzer
Copy link
Owner

Tenzer commented Feb 18, 2025

Oh, that's interesting! I do have my terminal of choice (Ghostty) in the list of apps allowed to contact the local network. Perhaps that's why it works for me.

@bindiry
Copy link
Author

bindiry commented Feb 18, 2025

Oh, that's interesting! I do have my terminal of choice (Ghostty) in the list of apps allowed to contact the local network. Perhaps that's why it works for me.

I checked my Local Network allowed list, and iTerm is also there and enabled. This is really strange.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants