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 protocol on local server? #682

Open
steveruizok opened this issue Jan 3, 2024 · 5 comments
Open

Wrong protocol on local server? #682

steveruizok opened this issue Jan 3, 2024 · 5 comments

Comments

@steveruizok
Copy link

When running npx partykit dev, the worker is hosted at three endpoints:

Build succeeded, starting server...
[pk:inf] Ready on http://0.0.0.0:1999
[pk:inf] - http://127.0.0.1:1999
[pk:inf] - http://192.168.0.214:1999

However, the third endpoint (http://192.168.0.214:1999) does not work because the "wss" protocol is used. This makes a server difficult to debug on a local network.

I think the following code is to blame:

(host.startsWith("localhost:") || host.startsWith("127.0.0.1:")
? // http / ws
defaultProtocol
: // https / wss
defaultProtocol + "s");

I've been unable to successfully patch the code to find out, but that's my guess!

@threepointone
Copy link
Contributor

Great catch, that's probably it. Fix incoming: #683

@threepointone
Copy link
Contributor

Fix available on partysocket@0.0.19 / y-partykit@0.0.12, lemme know if that does the trick!

@steveruizok
Copy link
Author

Thanks!

@Vaibhav-npc
Copy link

@threepointone

While integrating Docker containers, I encountered an issue where connections default to WSS despite specifying an HTTP URL in PARTY_KIT_URL=http://host.docker.internal:1999.
This behavior seems counterintuitive, especially when explicit protocols are defined by the user. Could we consider enhancing the logic to default to WS when the provided URL begins with HTTP, and only use WSS for HTTPS URLs?

For now, as a workaround, I am specifying explicitly in constructor:

const provider = new YPartyKitProvider(
  Deno.env.get('PARTY_KIT_URL'),
  record.id,
  yDoc,
  { protocol: "ws" }
);

I believe this could improve usability for scenarios involving Docker container connections. Is reopening the issue for further discussion or consideration possible?

@threepointone threepointone reopened this Mar 30, 2024
@threepointone
Copy link
Contributor

This is a good idea. Happy to take a PR

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

3 participants