Cant connect to websockets
#1
All,

I am trying to get notifications from headless kodi instance to then notify all the other head-ed instances to refresh their recently added lists

I am not able to connect using the code.

Code:
#!/usr/bin/python

from websocket import create_connection
ws = create_connection("ws://192.168.100.1:9090/jsonrpc")
print "World'..."
ws.send('{"jsonrpc": "2.0", "method": "Player.GetActivePlayers", "id": 1}')
print "Sent"
print "Reeiving..."
result =  ws.recv()
print "Received '%s'" % result
ws.close()

The root cause seems to be that kodi.bin isnt' listening on IPV4 IP for that 9090 TCP Port.

Code:
$ sudo netstat -ntlp | grep kodi
tcp        0      0 0.0.0.0:8080            0.0.0.0:*               LISTEN      11444/kodi.bin  
tcp        0      0 0.0.0.0:36666           0.0.0.0:*               LISTEN      11444/kodi.bin  
tcp6       0      0 :::9090                 :::*                    LISTEN      11444/kodi.bin  
tcp6       0      0 :::8080                 :::*                    LISTEN      11444/kodi.bin  
tcp6       0      0 :::36666                :::*                    LISTEN      11444/kodi.bin  
tcp6       0      0 :::36667                :::*                    LISTEN      11444/kodi.bin

Any ideas? I am using Kodi 14.1 on Ubuntu 64bit, disabling IPV6 at the OS level helps but I think this a bug?
Reply
#2
So by default it creates an IPv6 TCP socket on port 9090?
Always read the online manual (wiki), FAQ (wiki) and search the forum before posting.
Do not e-mail Team Kodi members directly asking for support. Read/follow the forum rules (wiki).
Please read the pages on troubleshooting (wiki) and bug reporting (wiki) before reporting issues.
Reply
#3
Isn't the websocket implementation on the TCP server? i.e. the address should be "ws://192.168.100.1:9090", i.e. without /jsonrpc? Perhaps that doesn't matter?
If you have problems please read this before posting

Always read the XBMC online-manual, FAQ and search the forum before posting.
Do not e-mail XBMC-Team members directly asking for support. Read/follow the forum rules.
For troubleshooting and bug reporting please make sure you read this first.

Image

"Well Im gonna download the code and look at it a bit but I'm certainly not a really good C/C++ programer but I'd help as much as I can, I mostly write in C#."
Reply
#4
(2015-02-11, 09:08)Montellese Wrote: So by default it creates an IPv6 TCP socket on port 9090?

yes that is what I am observing. unless I disable IPV6 i cannot access on regular ipv4 addresses. This is consistent across systems, I have another crystalbuntu and I see the same behaviour on there.
Reply
#5
(2015-02-11, 09:28)topfs2 Wrote: Isn't the websocket implementation on the TCP server? i.e. the address should be "ws://192.168.100.1:9090", i.e. without /jsonrpc? Perhaps that doesn't matter?

Tried both, neither work with IPv6 enabled, both work with IPv6 disabled. So I take it that it doesn't matter. The wiki link needs to be updated if this is the case.

http://kodi.wiki/view/JSON-RPC_API#WebSocket

Also the advancedsettings.xml 's disableipv6 was dropped somewhere along the way.
Reply
#6
how did you manage to disable ipv6 and have it take?

Code:
tcp6       0      0 :::9090                 :::*                    LISTEN      16904/kodi.bin
tcp6       0      0 :::8080                 :::*                    LISTEN      16904/kodi.bin

What's strange about that is that I always explicitly disable ipv6 system wide (and on my router for lan/wan). My two Kodi HTPC's are ubuntu 14.04LTS, so the method to disable ipv6 is to edit /etc/sysctl.conf and add the following lines (you then have to reload or reboot but anyway):

net.ipv6.conf.all.disable_ipv6 = 1
net.ipv6.conf.default.disable_ipv6 = 1
net.ipv6.conf.lo.disable_ipv6 = 1


I can confirm that it's "taken effect" by running cat /proc/sys/net/ipv6/conf/all/disable_ipv6 which returns "1" meaning it's been disabled. In both cases if I do ifconfig I don't see any ipv6 addresses.

Like you I had the disableipv6 directives in advancedsettings.xml but obviously those are either deprecated or not being obeyed.
Reply
#7
quick update, looks like the only real way to disable ipv6 is to add it to the grub options.

your PC doesn't load /etc/sysctl.conf at boot time (which is the case for me), disabling IPv6 from grub is needed. Linux kernel has a boot option named "ipv6.disable=1" which disables IPv6 from startup.

To edit the boot options, edit "/etc/default/grub" with any text editor as root user:

sudo nano /etc/default/grub
Find the line that contain "GRUB_CMDLINE_LINUX_DEFAULT":

GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"
Add "ipv6.disable=1" to the boot option, then save your grub file:

GRUB_CMDLINE_LINUX_DEFAULT="ipv6.disable=1 quiet splash"
Finally, update grub:

sudo update-grub
Reply
#8
I'm having some trouble with this too. I can connect to Kodi JSON RPC (running on Windows 8.1) via a websocket app in Chrome, but not using the websocket package in Python (running on the same computer as the Chrome app). With Python I get what I assume is the same error as the OP - i.e. Error 10060, the connection timed-out.

I've tried disabling IPv6, but that doesn't seem to help... Any other suggestions what to try?
Reply

Logout Mark Read Team Forum Stats Members Help
Cant connect to websockets0