Some requests not being routed over HTTPS

Issue description:

Some JSON-RPC requests are being sent over HTTP instead of HTTPS, with HTTPS enabled.

I have HTTPS enabled and it mostly works (I can view my library and such), but throws an error during setup like, “Unable to get Kodi version.” When I dig into the logs, it appears that some (successful) queries are going over HTTPS, while others are failing because they’re attempting HTTP.

Logs:

Successful query example:

2023-10-23 13:46:58.061 Verbose/KodiNexus: --> [381] POST https://osmc.mydomain.dev/jsonrpc (61-byte body)
2023-10-23 13:46:58.061 Verbose/KodiNexus: --> [381] {"id":871,"jsonrpc":"2.0","method":"Player.GetActivePlayers"}
2023-10-23 13:46:58.501 Verbose/KodiNexus: <-- [381] 200 OK https://osmc.mydomain.dev/jsonrpc (441ms, 38-byte body)
2023-10-23 13:46:58.505 Verbose/KodiNexus: <-- [381] {"id":871,"jsonrpc":"2.0","result":[]}

Failed Query Examples:

2023-10-23 13:47:09.438 Verbose/KodiHelix: --> [638] POST http://osmc.mydomain.dev:443/jsonrpc (106-byte body)
2023-10-23 13:47:09.439 Verbose/KodiHelix: --> [638] {"id":773,"jsonrpc":"2.0","method":"Application.GetProperties","params":{"properties":["version","name"]}}
2023-10-23 13:47:09.470 Verbose/KodiHelix: <-- [638] HTTP FAILED: java.io.IOException: unexpected end of stream on http://osmc.mydomain.dev:443/...
2023-10-23 13:47:09.475 Error/KodiHelix: Error
java.io.IOException: unexpected end of stream on http://osmc.mydomain.dev:443/...
	at hb.h.g(SourceFile:134)
	at a2.g.c(SourceFile:5)
	at gb.b.a(SourceFile:243)
	at gb.f.b(SourceFile:133)
	at fb.a.a(SourceFile:102)
	at gb.f.b(SourceFile:133)
	at db.a.a(SourceFile:151)
	at gb.f.b(SourceFile:133)
	at gb.a.a(SourceFile:135)
	at gb.f.b(SourceFile:133)
	at gb.g.a(SourceFile:141)
	at gb.f.b(SourceFile:133)
	at q3.d.a(SourceFile:129)
	at gb.f.b(SourceFile:133)
	at cf.e.a(SourceFile:81)
	at gb.f.b(SourceFile:133)
	at q3.c.a(SourceFile:419)
	at gb.f.b(SourceFile:133)
	at le.b.a(SourceFile:3)
	at gb.f.b(SourceFile:133)
	at fb.i.h(SourceFile:96)
	at fb.f.run(SourceFile:36)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:644)
	at java.lang.Thread.run(Thread.java:1012)
Caused by: java.io.EOFException: \n not found: limit=0 content=…
	at nb.r.e0(SourceFile:158)
	at hb.h.g(SourceFile:39)
	... 24 more
2023-10-23 13:47:09.439 Verbose/KodiHelix: --> [592] POST http://osmc.mydomain.dev:443/jsonrpc (53-byte body)
2023-10-23 13:47:09.439 Verbose/KodiHelix: --> [592] {"id":440,"jsonrpc":"2.0","method":"JSONRPC.Version"}
2023-10-23 13:47:09.472 Verbose/KodiHelix: <-- [592] HTTP FAILED: java.io.IOException: unexpected end of stream on http://osmc.mydomain.dev:443/...
2023-10-23 13:47:09.479 Verbose/KodiHelix: --> [560] POST http://osmc.mydomain.dev:443/jsonrpc (106-byte body)
2023-10-23 13:47:09.479 Verbose/KodiHelix: --> [560] {"id":658,"jsonrpc":"2.0","method":"Application.GetProperties","params":{"properties":["version","name"]}}
2023-10-23 13:47:09.501 Verbose/KodiHelix: <-- [560] HTTP FAILED: java.io.IOException: unexpected end of stream on http://osmc.mydomain.dev:443/...

I would love to see the scheme consistently applied so it doesn’t throw errors.

I need proper logs not small extracts …

Scheme is properly applied if you add the host correctly. You probably edited the host and forget to change the connection type.

Provide logs when adding the host from scratch.

I removed the host and added it back. Same result. Requests are split between HTTP and HTTPS, all going to the same port.

debug.log (47.2 KB)

They are not split, there’s a few http calls as tests during host add. (You can see them as KodiHelix)

But all the host calls on the nexus host KodiNexus are https.

Yatse surfaces feedback that the request failed, which is misleading, since it actually works.

Is this after editing the host that was already added via the wizard ?

What does the connection type says in the advanced tab?

HTTPS (no cert checks)

This message shows again if I click the “Check” button.

Hum makes no sense as it’s the same tests as the add wizard.

Anyway to have a test access to the server to see what is happening?

I’m not really set up for external access, but I see the same behavior with curl. The server is not listening on port 80.

$ curl -u ***:*** -k https://osmc.mydomain.dev/jsonrpc -X POST -d '{"id":1,"jsonrpc":"2.0","method":"JSONRPC.Version"}' -H "Content-Type: application/json"
{"id":1,"jsonrpc":"2.0","result":{"version":{"major":13,"minor":0,"patch":0}}}%

$ curl -u ***:*** -k http://osmc.mydomain.dev/jsonrpc -X POST -d '{"id":2,"jsonrpc":"2.0","method":"JSONRPC.Version"}' -H "Content-Type: application/json"
curl: (7) Failed to connect to osmc.mydomain.dev port 80 after 26 ms: Couldn't connect to server

Is there a reason you think the “Unable to get Kodi version” error is not related to sending that request over HTTP instead of HTTPS, as seen in the logs?

The test is http protocol but on the proper port so not your curl test.

And if you can add the host then the test pass, the fact that the same test fails after editing an host is the issue here as it’s the same code that does the test.

Without access it’s hard to know what is really happening.