Communicate with embedded HTTP Server via XTC_APP_ENDPOINT

155 Views Asked by At

I'm referring to the implementation outlined in this video: https://www.youtube.com/watch?v=mnAenNaEpJk

This works fine running locally using the IP address of my device over any port (as long as the client and server use the same port).

Test client:

var url = isTestCloud ? Environment.GetEnvironmentVariable("XTC_APP_ENDPOINT") : "http://" + deviceIp + ":8081";
HttpClient client = new HttpClient {
    BaseAddress = new Uri(url),
};

In App:

HttpListener _listener = new HttpListener();
var prefixes = new [] {
    "http://*:8081/",
};
foreach (string s in prefixes)
    _listener.Prefixes.Add (s);
_listener.Start ();

This works great running locally, but when trying to run in Test Cloud, I get a System.TimeoutException in my Test while trying to connect to the game server.

From the video, James makes it clear that you must be listening on port 8081, however this was a couple of years ago and I'm wondering if it has changed. I also tried changing 8081 to 37777. But I still had the same result.

I noticed the XTC_APP_ENDPOINT env variable returns something like: http://devicehost7.prod:37777/wd/token-1acaf8c0-2987-4a49-aa5b-3ab795ecb910/

I adjusted my server to use 37777, same result. I tried again adjusting my prefix: var prefixes = new [] { "http://*:37777/*/token-*/", };, but always get the same result (System.TimeoutException).

Is there any documentation I can read up on regarding how to interact with an embedded HTTP server? Or can someone point me in the right direction?

Thanks, Loren

1

There are 1 best solutions below

0
On

After speaking with support, it seems TestCloud was producing an incorrect value for XTC_APP_ENDPOINT.

They've addressed it, and now my original code now works perfectly over port 8081!