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

Connect via URL instead of IP #72

Closed
MykonCodes opened this issue Mar 4, 2018 · 19 comments
Closed

Connect via URL instead of IP #72

MykonCodes opened this issue Mar 4, 2018 · 19 comments

Comments

@MykonCodes
Copy link

Hey.

Currently having no success establishing a connection when using an URL as the parameter for the Connect function instead of an IP Adress. We'll be using a load balancer and therefore the IP of our servers will change. Is there any integrated way of connecting to an URL instead?

All the best,
Mykon

@getnamo
Copy link
Owner

getnamo commented Mar 4, 2018

This already works, e.g. https://github.com/getnamo/tensorflow-ue4-examples/blob/master/Content/ExampleAssets/Blueprints/ConnectedTFMnistActor.uasset uses http://qnova.io:3000 for the address and port to support web-based input for classification.

Just make sure you specify both url and port http://{your url}:{socketio port}. Default http port btw is 80.

@MykonCodes
Copy link
Author

Thanks for the quick response, however that doesn't work for us.

The logger of the underlying socketIO impl do not output to the UE4 logs, but with manual debugging I found the error code being "pass_through - Underlying Transport Error". No clue what that means. Tried it with port, without, with leading http:// and https:// and without. And those IP's that do work resolve to the exact same IP's. JS SocketIO has no issue connecting to the same URL's.

@getnamo
Copy link
Owner

getnamo commented Mar 4, 2018

NB: https isn't currently supported see #39. Make sure you're not using SSL

@MykonCodes
Copy link
Author

MykonCodes commented Mar 4, 2018

I just tested with it, we don't require https. Edit: And we don't use SSL.

@getnamo
Copy link
Owner

getnamo commented Mar 5, 2018

Have you tried a url at the root domain? e.g. like http://qnova.io:3000 I haven't personally figured out how to get the path option to work with servers (https://socket.io/docs/server-api/#new-server-httpserver-options) we might need a to handle path in a special way on connection like the javascript client does in the io([url],[options]) function (https://socket.io/docs/client-api/#io-url-options)

We'd could use a working minimal example of a server with path and javascript client with path to see what's missing in the c++ client.

@MykonCodes
Copy link
Author

Sorry that I didn't respond, had some other issues to work on. And I was being stupid, sorry for that, we indeed use HTTPS. Now I am 99% sure I tested on non-https too, but maybe I had a typo or something, I don't know, at least non https URL's now work, but yeah.. Really need HTTPS to work. So I'll look into how to enable it.

@MykonCodes
Copy link
Author

So I spend the whole day trying to get OpenSSL working, and it is a total pain in the ***. To get everything running for a x64 machine. Eventually I tried 5 different versions of socket io cpp, got OpenSSL integrated and UE4 starting up 2 times, but only to find out that now no IP or URL at all works anymore..

@MykonCodes
Copy link
Author

My current run is using your prebuild repository, where I had to tweak a ton already to make CMake build with OpenSSL and find the proper boost libs, but yeah... When I bind the sioclient_tls.lib, it just doesn't work.. Spits out ITERATOR_DEBUG_LEVEL mismatches when I try to use the debug build, so I can't debug it either..

@getnamo
Copy link
Owner

getnamo commented Mar 8, 2018

It's awesome to have another pair of eyes on getting this set up. Getting everything to splice even for the regular non-ssl version was always a day affair for me and I'm frankly a noob at cmake. If you get a working build, consider making a pull request on prebuild and here.

Regarding TLS, Have you had a look at these two issues

socketio/socket.io-client-cpp#13
and
socketio/socket.io-client-cpp#46?

First issue should point at code changes that were needed for TLS work with socket.io and issue 46 points to needing a macro define for things to compile. Other than that you can still run UE4 in debug mode while having release libraries linked which may hint at where the issue may lie even if the lib code is not all exposed.

@MykonCodes
Copy link
Author

MykonCodes commented Mar 8, 2018

Got it working. It required a ton of cheat-arounds though and god do I hate CMake. Same goes for me, I know the basics of it but I want to vomit each time I have to use it :P

Had to change the CMakeList.txt, add a bunch of dll's, windows lib's, and even change some websocketpp code that just didnt wanted to compile (just an undefined enum, so I hardcoded the integer value in). Another PITA was x64 vs x86, as I couldnt get anything with x86 to run I had to figure out how to make CMake build x64 solutions.

I'll see if I can figure out a way to do a pull request, however I noticed that connections to normal HTTP servers don't work anymore with TLS enabled. I can share the code privatly with you first if you also want to have a look on how to use TLS only when applicable.

@getnamo
Copy link
Owner

getnamo commented Mar 9, 2018

I'd be definitely interested in the build configs changed for ssl and working prebuilt libraries (.lib). Even if it is a trade off atm it would get us closer to getting a full solution. What I've done is open a new branch called windows-ssl on the prebuild here https://github.com/getnamo/socketio-client-ue4/tree/windows-ssl and if you make a pull there we will have it for reference when trying to get a holistic solution.

@MykonCodes
Copy link
Author

Alright, I will see if I can get anything useful together. Issue here is I have around 5-6 sioclient projects on my PC now and I think I even had to use a special version of the websocketpp repo. If I create a pull request I at least want it to be somewhat useable and approved, so it might take me a bit. Also, you created the branch on the plugin, not the prebuild. :)

@getnamo
Copy link
Owner

getnamo commented Mar 9, 2018

Whoops :)! here's the new branch https://github.com/getnamo/socketio-client-prebuild/tree/windows-ssl

Note that the pre-build uses submodules: https://github.com/getnamo/socketio-client-prebuild/tree/windows-ssl/src which then depends on submodules: https://github.com/getnamo/socket.io-client-cpp/tree/bfa0a53a4851cbbd56d4606c6d6fbed3f81a964b/lib so you can also add pull requests there to update the websocket library and it will all be contained :) (made a branch there too: https://github.com/getnamo/socket.io-client-cpp/tree/ssl-fixes)

@MykonCodes
Copy link
Author

MykonCodes commented Mar 9, 2018

As I currently have a ton to do, for now I zipped up the socket io cpp folder with the cmake files and everything. https://www.dropbox.com/s/rukc165a0uj91m1/socket.io-client-cpp.zip?dl=0

I also had to make TLS to use the OpenSSL of UE4 (because otherwise there were multiple definitions of the crypto lib while packaging), so you will need to replace the reference to it in the sioclient_tls project. I think I only have the working settings in the configuration RelWithDebInfo x64.

And here the (messy) build.cs
https://www.dropbox.com/s/vkknmklnuh37vaw/SocketIOClient.Build.cs?dl=0

btw the lib's I link in the build.cs are part Windows,
(C:\Program Files (x86)\Windows Kits\10\Lib\10.0.15063.0\um\x86\User32.Lib etc)

@AgrYpn1a
Copy link

AgrYpn1a commented Sep 9, 2018

Hey, any updates on this?

@getnamo
Copy link
Owner

getnamo commented Sep 10, 2018

The issue lies at the underlying websocketpp library, which requires an update to support TLS and non TLS endpoints at the same time. Some movement has been made toward providing easy examples to support this here zaphoyd/websocketpp#734 and here zaphoyd/websocketpp#706

Once an example is available for reference in order to update https://github.com/socketio/socket.io-client-cpp we can merge that in when we recompile the library for this plugin's use.

Contributions are welcome!

@AgrYpn1a
Copy link

AgrYpn1a commented Sep 10, 2018

Okay, I followed links, and found this commit socketio/socket.io-client-cpp#137. I managed to integrate it in socket.io and build the lib. How can I recompile your plugin in order to test if everything is working correctly?

--- This basically adds a new constructor that accepts url as parameter, then call connect() with no parameters to connect, and based on url it will determine whether to use https or http.

EDIT: Figured it out, should add those files directly to ue4 plugins/socketio-client-u4/Source. Trying to build now, will report later what happened.

UPDATE: Getting bunch of LINK errors, unresolved externals and mismatches after adding modified plugin lib and headers.

UPDATE2: Here's the error log https://gist.github.com/rastko1996/5ef59b8aaf6ee80cf27946534cdf8182

@MykonCodes
Copy link
Author

Will take a peek at that when I have the time, maybe on saturday. It's been a while since I got it working and didn't touch it since.

@ughstudios
Copy link

Why hasn't this been added to the main repo before this guys dropbox takes that script down??

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants