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

Wrong /axis-cgi/rtspwssession.cgi url when using BasicPlayer #856

Open
SampsaKaskela opened this issue Nov 30, 2023 · 1 comment
Open

Wrong /axis-cgi/rtspwssession.cgi url when using BasicPlayer #856

SampsaKaskela opened this issue Nov 30, 2023 · 1 comment
Labels
bug Something isn't working

Comments

@SampsaKaskela
Copy link

SampsaKaskela commented Nov 30, 2023

Describe the bug
I'm using BasicPlayer component from media-stream-player. I give it hostname prop which contains my camera hostname (192.168.220.70) and format (RTP_H264). Then when camera starts it begins connecting to following urls:

ws://192.168.220.70/rtsp-over-websocket
http://localhost:5173/axis-cgi/rtspwssession.cgi?1701346271345

This is clearly wrong. It should not make request to localhost (that is where my UI is run with Vite) but to hostname that was given so correct would probably be

http://192.168.220.70/axis-cgi/rtspwssession.cgi?1701346271345

To Reproduce
Import BasicPlayer component and give it hostname and format RTP_H264. Check console for urls where it tries to connect.

Environment (please complete the following information):

  • OS: Windows 10 Enterprise
  • Browser: Chrome Version 119.0.6045.161 (Official Build) (64-bit)
  • Version 13.1.0

Additional context
I suspect the problem might be in WsRtspVideo component that BasicPlayer uses internally. WsRtspVideo component opens Html5VideoPipeline and gives it ws config { uri: "ws url here" }. But when it opens websocket it merges with default config which is calculated like this in current code:

const defaultConfig = (
  host: string = window.location.host,
  scheme: string = window.location.protocol
): WSConfig => {
  const wsScheme = scheme === 'https:' ? 'wss:' : 'ws:'

  return {
    uri: `${wsScheme}//${host}/rtsp-over-websocket`,
    tokenUri: `${scheme}//${host}/axis-cgi/rtspwssession.cgi`,
    protocol: 'binary',
    timeout: WEBSOCKET_TIMEOUT,
  }
}

So since it merges default config and given ws config then that tokenUri part ends up being wrong. Fix maybe could be that instead of giving { uri: ws } you would give it { host: "myHost" } since defaultConfig function is called with defaultConfig(config.host, config.scheme) so in this case it should then calculate uri and tokenUri correctly. Alternatively you could pass { uri: ws, tokenUri: wsTokenUri } and that would probably work too.

@SampsaKaskela SampsaKaskela added the bug Something isn't working label Nov 30, 2023
@SampsaKaskela
Copy link
Author

I tried adding the tokenUri to config by hardcoding the correct uri in and it seemed to work. The issues then ended up being that since my camera requires Authorization header to authenticate then I got 401 response because it was missing from request and there seemed to be no way to add Authorization header to request. After hard coding that into openWebsocket function then the request went through and stream opened. This might be separate issue tho since currently there doesn't seem to be way to include Authorization header to that request and so that request is kind of useless without that functionality.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant