[GH-ISSUE #92] Websocket not authorised for host #65

Closed
opened 2026-02-28 14:25:05 +03:00 by kerem · 5 comments
Owner

Originally created by @Willyarma on GitHub (Sep 11, 2024).
Original GitHub issue: https://github.com/devgianlu/go-librespot/issues/92

I'm getting this message:

time="2024-09-11T10:43:47+01:00" level=error msg="failed accepting websocket connection" error="failed to accept WebSocket connection: request Origin "http://192.168.5.49:8888" is not authorized for Host "192.168.5.49:3678""

Am I doing something wrong?

config.yml:
device_name: go-librespot
credentials:
type: zeroconf
server:
enabled: true
port: 3678

Originally created by @Willyarma on GitHub (Sep 11, 2024). Original GitHub issue: https://github.com/devgianlu/go-librespot/issues/92 I'm getting this message: time="2024-09-11T10:43:47+01:00" level=error msg="failed accepting websocket connection" error="failed to accept WebSocket connection: request Origin \"http://192.168.5.49:8888\" is not authorized for Host \"192.168.5.49:3678\"" Am I doing something wrong? config.yml: device_name: go-librespot credentials: type: zeroconf server: enabled: true port: 3678
kerem 2026-02-28 14:25:05 +03:00
  • closed this issue
  • added the
    bug
    label
Author
Owner

@Willyarma commented on GitHub (Sep 11, 2024):

I added allow_origin: "http://192.168.5.49:8888" to the config.yml and it only affects the get and post part of the API it does not affect the websocket. Putting "*" dosent work either for websockets but does for get/post.

<!-- gh-comment-id:2343493001 --> @Willyarma commented on GitHub (Sep 11, 2024): I added allow_origin: "http://192.168.5.49:8888" to the config.yml and it only affects the get and post part of the API it does not affect the websocket. Putting "*" dosent work either for websockets but does for get/post.
Author
Owner

@Willyarma commented on GitHub (Sep 11, 2024):

I hacked it for the time being just to get it going...

m.HandleFunc("/events", func(w http.ResponseWriter, r *http.Request) {
	opts := &websocket.AcceptOptions{}
	if len(s.allowOrigin) > 0 {
		//opts.OriginPatterns = []string{s.allowOrigin}
	}
	opts.InsecureSkipVerify = true

obviously this isnt the right way

<!-- gh-comment-id:2343843038 --> @Willyarma commented on GitHub (Sep 11, 2024): I hacked it for the time being just to get it going... m.HandleFunc("/events", func(w http.ResponseWriter, r *http.Request) { opts := &websocket.AcceptOptions{} if len(s.allowOrigin) > 0 { //opts.OriginPatterns = []string{s.allowOrigin} } opts.InsecureSkipVerify = true obviously this isnt the right way
Author
Owner

@devgianlu commented on GitHub (Sep 15, 2024):

@Willyarma Can you test again with the latest changes?

<!-- gh-comment-id:2351603351 --> @devgianlu commented on GitHub (Sep 15, 2024): @Willyarma Can you test again with the latest changes?
Author
Owner

@Willyarma commented on GitHub (Sep 15, 2024):

I'm using a node.js wrapper that I wrote with a minimal web interface, the HTTP server of it is on port 8888.

Without specifying allow_origin in config.yml, get/post gives cors errors in the firefox web console, the websocket won't connect.

allow_origin: "*" works for both get/post and websockets
allow_origin: "http://192.168.5.49:8888" also works
allow_origin: "192.168.5.49:8888" only works for websockets

Would it be worth mentioning requiring allow_origin in the main readme?

Thanks for fixing it so quickly.

<!-- gh-comment-id:2351711271 --> @Willyarma commented on GitHub (Sep 15, 2024): I'm using a node.js wrapper that I wrote with a minimal web interface, the HTTP server of it is on port 8888. Without specifying allow_origin in config.yml, get/post gives cors errors in the firefox web console, the websocket won't connect. allow_origin: "*" works for both get/post and websockets allow_origin: "http://192.168.5.49:8888" also works allow_origin: "192.168.5.49:8888" only works for websockets Would it be worth mentioning requiring allow_origin in the main readme? Thanks for fixing it so quickly.
Author
Owner

@devgianlu commented on GitHub (Sep 16, 2024):

Added to the README for clarity. Thank you for reporting!

<!-- gh-comment-id:2352318199 --> @devgianlu commented on GitHub (Sep 16, 2024): Added to the README for clarity. Thank you for reporting!
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/go-librespot#65
No description provided.