Skip to content

ALB query string listener not working for websockets

0

Hello,

I am currently facing a weird issue with ALB which I need help with. I am currently trying out Unreal Engine Pixel Streaming on EC2 and there are no issues if I access the EC2's public URL directly.

I have created an ALB with a listener that forwards to several target groups. The condition to which target group to go to is based on Query String. This is where things get weird.

Listener rules settings

  • Rule01 => Query string session=ins01 will go to TG1 which has an EC2 inside
  • Default => TG2 which has a non working EC2 inside (on purpose for testing)

When I try to access the ALB with the query string, I will always get a status 304 and there will be a white screen. But when I change the Default to map to TG1 and I deleted Rule01 away, I am able to access my EC2 instance without any issues.

To ensure that the query string routing is working, I launched an EC2 with just a simple apache server and mapped it into TG1 and it works, but its not working for the pixelstreaming server with websockets.

Does anyone have an issue with Query String routing for ALB with websockets? Thanks!

asked 2 years ago382 views

2 Answers
0

You might want to enable access (request) logging for the ALB: https://docs.aws.amazon.com/elasticloadbalancing/latest/application/enable-access-logging.html

The "request" field in the log (https://docs.aws.amazon.com/elasticloadbalancing/latest/application/load-balancer-access-logs.html#access-log-entry-syntax) would show exactly what query string parameters the ALB reports it's received when the request routing isn't working in the expected way.

You can use Athena to query the access logs conveniently: https://docs.aws.amazon.com/athena/latest/ug/application-load-balancer-logs.html

EXPERT

answered 2 years ago

  • Thank you for the reply.

    I've checked the logs and webserver and managed to pinpoint the issue. The Query string routing is actually correct and it runs the html, however the javascript inside the HTML <script defer="defer" src="player.js"></script> is returning an error 503 when I try to access it

    However, if I have a valid Target Group set to my default, it will work by using the player.js inside the default Target Group's EC2 instead of its own player.js

    Is there any way I can fix this?

  • Sorry for the double comment.

    the error 503 is Failed to load resource.

0

The issue you're experiencing with ALB query string routing for websockets in the context of Unreal Engine Pixel Streaming is likely related to the specific requirements of websocket connections and how they interact with ALB routing rules.

For Unreal Engine Pixel Streaming, which relies heavily on websocket connections, a more specialized approach is typically needed when using an Application Load Balancer (ALB). The standard query string-based routing might not be sufficient for maintaining the websocket connection properly.

Instead of using query string-based routing, a recommended approach for Pixel Streaming with ALB is to use a combination of AWS Lambda functions and Amazon EventBridge to manage the routing of websocket connections. This method involves:

  1. Using AWS Lambda to register the signaling servers to an ALB target group.
  2. Creating a unique query string for each signaling server when it's registered to the ALB target group.
  3. Using an ALB listener rule that allows accessing a specific signaling server based on this unique query string.
  4. Employing another AWS Lambda function to relay the correct query string to the user via a WebSocket connection, ensuring the user is directed to the designated signaling server for their session.

This approach allows for more dynamic and precise routing of websocket connections, which is crucial for the proper functioning of Pixel Streaming.

The reason your setup works when you set the default action to forward to the target group with the working EC2 instance is that it bypasses the need for specific routing rules. However, this solution doesn't scale well for multiple instances or provide the level of control needed for a production Pixel Streaming deployment.

To resolve your issue, consider implementing the more complex but robust solution using Lambda functions and EventBridge for managing your signaling servers and routing websocket connections. This will provide a more reliable and scalable setup for Unreal Engine Pixel Streaming on AWS.
Sources
Deploy Unreal Engines Pixel Streaming at scale on AWS | AWS for Games Blog

answered 2 years ago

  • Just to clarify certain points that the GenAI wrote

    The issue I am having is that query string routing is not working at all for websockets, but when I run an apache server, it works. The default rule that forwards to target group for websockets is working, but when the target group that was working in default is set to a rule with query string conditions it won't work

    So I am trying to figure out why that is the issue.

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.