embedded-app-sdk
embedded-app-sdk copied to clipboard
Cannot use Hathora with Discord Activities
Hathora cannot be used with Discord Activities unfortunately. Discord Activities requires every outbound connection from your client application to go through a Discord proxy (discordsays.com) where you map endpoints to their respective URLs. The endpoint mapping does not support ports other than the standard 80 and 443 and all Hathora edge services such as ping endpoints and the actual game rooms require specific ports to be used. An example URL for a game room looks like this: wss://86d96a.edge.hathora.dev:51738
where both subdomain and port can change frequently.
Enabling port forwarding for URL mappings would resolve this issue. Another solution would be to allow URL mapping targets to support port
as well as hostname
. The port
should also support parameter matching for this to work.
Here's an example of the latter:
Update Someone else filed the same issue here: https://github.com/discord/embedded-app-sdk/issues/50
I believe you can already add a port to the URL mapping!
It did not work for me, and their docs explain why here: https://discord.com/developers/docs/activities/development-guides#activity-proxy-considerations
You can use these ports: https://developers.cloudflare.com/fundamentals/reference/network-ports/#network-ports-compatible-with-cloudflares-proxy
You can use these ports: https://developers.cloudflare.com/fundamentals/reference/network-ports/#network-ports-compatible-with-cloudflares-proxy
That does not resolve this issue unfortunately. Hathora uses more than 6 different ports and none of them are on that list.
Our docs actually link to the wrong docs in cloudflare. The correct docs are here: https://developers.cloudflare.com/rules/origin-rules/features/#destination-port, which states that all ports are allowed. however, there does seem to be a problem here. we're investigating further.
@devsnek any updates on the investigation you can share by chance? I'm super eager to get my game integrated as an activity and this is really my only blocker.
I am also having this issue, but with sub-domains! I dynamically generate new subdomains on my base domain for each kubernetes node added to a cluster. Without the ability to add parameters, I will have to write some code to constantly call the discord developer apis to update the URL mapping list, which seems like a bad idea.
I am also having this issue, but with sub-domains! I dynamically generate new subdomains on my base domain for each kubernetes node added to a cluster. Without the ability to add parameters, I will have to write some code to constantly call the discord developer apis to update the URL mapping list, which seems like a bad idea.
Parameters are already available for subdomains and they do work. They just don't work for ports yet.
Parameters are already available for subdomains and they do work. They just don't work for ports yet.
Just realized that today, not sure how I missed it in the docs. Unfortunately, we still have the same issues with ports as well, but are thinking of using HAProxy as a way to solve it for now
Any updates or guidance?
Unfortunately, this is ultimately a limitation of our proxy today. More info is documented here. We're working with Cloudflare to see what it could take to patch this behavior, but in the meantime (per the suggestion made by @sam-bunger about HAProxy), at the cost of an additional server "jump" you could route traffic to a server you own, i.e.
Request to discord Proxy: wss://1234.discordsays.com/hathora/51738 Maps to your activity at: wss://my-game.com/hathora/51738 Which you could remap: wss://abcd.edge.hathora.dev:51738
This is not ideal, but an extra server for proxying traffic should unblock you. Again, we're working with Cloudflare to understand a long-term solution to improve this and will make an announcement over in the Discord Developers server in the #api-announcements channel if/when we're able to resolve this.
@matthova Thank you for the update and the potential workaround.
Unfortunately, adding a proxy in front of the Hathora game servers defeats the purpose of using Hathora for its multi-regional capabilities. Hathora is able to spin up a game room in 1 of 11 regions closest to the players. If I set up a proxy it would force players to connect to the proxy in some location that may not be ideal for them at all. The other option would be to setup proxies in front of all 11 regions that Hathora currently supports to maintain that regional support and offer players the best latency possible.
I have also heard mentions of Cloudflare Spectrum, is this something you have looked into? https://developers.cloudflare.com/spectrum/reference/configuration-options/#ports
Is it possible to keep this issue open as it is still very much an issue that is preventing developers from using Hathora to develop Discord Activities?
Seconding to keep this issue open!