Giter Club home page Giter Club logo

multiplayerserversecurewebsocket's Introduction

This repository contains sample code for building a reverse proxy that enables web socket connections over https to PlayFab hosted multiplayer servers. This repository is not an official solution, but a starting point for developers who intend to deploy their multiplayer game to a browser.

The problem

Developers that intend to deploy their multiplayer game on the web face a problem when server connections originate from a https:// domain. PlayFab hosted game servers are typically hosted from a subdomain of azure.com. For security reasons, PlayFab cannot issue SSL certificates to developers to use for azure.com.

Browser security policies require that web socket connections originating from https:// are created with a secure connection (web socket over https or wss://).

A solution

A reverse proxy can be used to forward requests from a https:// domain to a PlayFab hosted game server, without the need for an SSL certificate on the game server.

Consider the following browser client flow

  1. The client retrieves the build ID, session ID, and region for an active server. This is typically taken from the result of a call to Request Multiplayer Server.
  2. Your game's browser client initiates a connection with the server details
    • If you owned the domain my-domain.com the request would be wss://my-domain.com/{buildId}/{sessionId}/{region}
  3. The reverse proxy looks up the server details and forwards the request to the server's fully qualified domain name - a subdomain of azure.com.

Connecting to a match diagram

Servers allocated by Matchmaking

The previous flow could be modified to use the Matchmaking API. Build ID, session ID, and region would be replaced with the the match ID and queue name returned from Create Matchmaking Ticket.

Deployment

This Dockerfile creates a HTTP server that handles requests at /{buildId}/{sessionId}/{region}/{**forwardPath}. Requests are proxied to a game server in the Active state that was requested with Request Multiplayer Server.

https://github.com/PlayFab/MultiplayerServerSecureWebsocket/blob/27d9fa0b0db6a5cd2bcf7f2ba13fa0ba713fa7ee/GameServer.ReverseProxy/Startup.cs#L99

The docker application is intended to be deployed as a web service that is separate from your game server. Game servers deployed as HTTP hosts run into the same issue that the repository MultiplayerServerSecureWebsocket mentions as a problem for games hosted on a https domain - you can't generate a SSL certificate for the fully qualified azure.com domain name of each server session.

Azure App Service is an "off the shelf" solution for the docker application. Linux and Windows should be supported since .NET Core is cross platform.

Integrating with your web client

When your web client configures a web socket connection i.e. ConnectEndpoint with Unity or WebSocket in client side JavaScript, you'll use the fully qualified domain name from your deployed web service.

For example, if you created an Azure App Service, the full qualified domain name would be something like https://myreverseproxy.azurewebsites.net/{buildId}/{sessionId}/{region}/

Need help?

While this is not an official solution, the best channel to discuss this respository or receive help is to use the Discussion section.

multiplayerserversecurewebsocket's People

Contributors

austinbrunkhorst avatar dependabot[bot] avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.