Announcement

Collapse
No announcement yet.

[Plugin] Socket.io Client

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

    Hello,

    I'm trying to implement this plugin with a python server also using socketio. I'm able to connect to the server and emit a message but when a try to receive from the server, UE keep crashing.

    I haven't been able to find a solution to my problem.


    Click image for larger version

Name:	console_result.JPG
Views:	1
Size:	16.2 KB
ID:	1543239

    Error in UE editor :
    Click image for larger version

Name:	Error_socketio_project.JPG
Views:	1
Size:	19.8 KB
ID:	1543234



    Log file
    Click image for larger version

Name:	Log_file_error_socketio_project_2.JPG
Views:	1
Size:	475.2 KB
ID:	1543235





    As I understand it, I couldn't bind an event. I couldn't find why...


    Here is my server code (python 3.7)

    Code:
    from aiohttp import web
    import socketio
    from colorama import init, Fore
    init(autoreset=True)
    
    sio = socketio.AsyncServer()
    app = web.Application()
    sio.attach(app)
    #sio.manager.set_server
    
    
    async def index(request):
       with open('index.html') as f:
         return web.Response(text=f.read(), content_type='text/html')
    
    @sio.on('connect', namespace="/")
    def connect(sid, env):
        print(Fore.RED + "connect ", sid)
    
    @sio.on('test', namespace="/")
    async def message(sid, data):
        print(Fore.GREEN + "message << ", data)
        await sio.emit('reply', "Hi i'm the server", sid)
    
    @sio.on('disconnect', namespace="/")
    def disconnect(sid):
        print(Fore.RED + 'disconnect', sid)
    
    #app.router.add_static('/static', 'static')
    app.router.add_get('/', index)
    
    
    if __name__ == '__main__':
        web.run_app(app)

    Blueprints
    Click image for larger version

Name:	Bp_socketio_project_1.JPG
Views:	2
Size:	204.5 KB
ID:	1543237

    Click image for larger version

Name:	Bp_socketio_project_2.JPG
Views:	1
Size:	125.9 KB
ID:	1543238


    Does anyone have an idea on how to solve this?

    Thank you,
    Attached Files

    Comment


      Originally posted by MagikarpWithATie View Post
      Hello,

      I'm trying to implement this plugin with a python server also using socketio. I'm able to connect to the server and emit a message but when a try to receive from the server, UE keep crashing.

      I haven't been able to find a solution to my problem.


      ...

      Does anyone have an idea on how to solve this?

      Thank you,
      It looks like your reply is an array (["Hi i'm the server", sid])

      Code:
      await sio.emit('reply', "Hi i'm the server", sid)
      out of curiosity does it crash if you remove the last variable?

      Code:
      await sio.emit('reply', "Hi i'm the server")
      have you tried embedding the sid response in an array? e.g.

      Code:
      await sio.emit('reply', ["Hi i'm the server", str(sid]))
      It may be that the function AsString is failing in detecting array SIOJsonValues. I've opened an issue on the plugin here: https://github.com/getnamo/socketio-...ue4/issues/102 for this problem, feel free to continue the discussion there.
      Plugins: TensorFlow - Socket.io Client - ZipUtility - Leap Motion - Hydra - Myo - RealSense - CIM

      Comment


        Hi, this plugin need some any extra install?
        Installed from marketplace, tryed the client sample, but not connetcting to server, don't get any error.
        Tryed from pc and android too. The server is run by another phone (work because can connect, send data with another client app).
        Ip and port is good.
        Created exe, added to firewall exception, still not work.
        Packaged to android phone (android 7), not connect to the server.
        4.20.3 UE version.

        Any idea?

        Comment


          Originally posted by Hermyth View Post
          Hi, this plugin need some any extra install?
          Installed from marketplace, tryed the client sample, but not connetcting to server, don't get any error.
          Tryed from pc and android too. The server is run by another phone (work because can connect, send data with another client app).
          Ip and port is good.
          Created exe, added to firewall exception, still not work.
          Packaged to android phone (android 7), not connect to the server.
          4.20.3 UE version.

          Any idea?
          Android is not yet supported, only windows and linux. Also make sure you're using http not https. See https://github.com/getnamo/socketio-client-ue4-example for example documentation.
          Plugins: TensorFlow - Socket.io Client - ZipUtility - Leap Motion - Hydra - Myo - RealSense - CIM

          Comment


            Good day, how i can connect to dynamicly created room, can you explain?

            Comment


              Originally posted by Kelt View Post
              Good day, how i can connect to dynamicly created room, can you explain?
              From a quick scan of the feature, it appears to be server based.

              Follow e.g. http://psitsmike.com/2011/10/node-js...chat-tutorial/ and https://stackoverflow.com/questions/...s-in-socket-io to implement it on the server. On the client you'd only need an emit call to switch to the new room and the server handles the switch, in the stack overflow answer the server then emits a message back to the client to do any room update logic (in that example 'updaterooms').
              Plugins: TensorFlow - Socket.io Client - ZipUtility - Leap Motion - Hydra - Myo - RealSense - CIM

              Comment


                Originally posted by getnamo View Post

                From a quick scan of the feature, it appears to be server based.

                Follow e.g. http://psitsmike.com/2011/10/node-js...chat-tutorial/ and https://stackoverflow.com/questions/...s-in-socket-io to implement it on the server. On the client you'd only need an emit call to switch to the new room and the server handles the switch, in the stack overflow answer the server then emits a message back to the client to do any room update logic (in that example 'updaterooms').
                Good day, it's mean on server side i wrote emit logic for connect new room and than "On Event" i can get message from server?

                Comment


                  I already try to emit connect to room, but i try send data into room from web-page to unreal with "On Event" and it's not work.
                  Last edited by Kelt; 02-14-2019, 01:20 PM.

                  Comment


                    Originally posted by Kelt View Post
                    I already try to emit connect to room, but i try send data into room from web-page to unreal with "On Event" and it's not work.
                    Did you bind your event so that it can be seen by 'On Event'? see https://github.com/getnamo/socketio-...se---bp-basics
                    Plugins: TensorFlow - Socket.io Client - ZipUtility - Leap Motion - Hydra - Myo - RealSense - CIM

                    Comment


                      Originally posted by getnamo View Post

                      Did you bind your event so that it can be seen by 'On Event'? see https://github.com/getnamo/socketio-...se---bp-basics
                      Sorry for delay. Already found troubles, it's my missed. I have question: why after connection stoped and server start again unreal can't connect to server.

                      Comment


                        Originally posted by Kelt View Post

                        Sorry for delay. Already found troubles, it's my missed. I have question: why after connection stoped and server start again unreal can't connect to server.
                        You'll have to be more specifc with the details of what you're doing, describe it step by step. The plugin does automatically reconnect to servers if you stop them and restart them. There may be ~5-25 second delay before the connection is re-established depending on how long you've been disconnected though (you can change reconnection settings directly on the socketio client component).
                        Plugins: TensorFlow - Socket.io Client - ZipUtility - Leap Motion - Hydra - Myo - RealSense - CIM

                        Comment


                          getnamo - thanks a million for this plugin. Diving into it now. I'm really interested in using it to communicate with an IRC server to send and retrieve messages. I'm having trouble figuring how how to begin this using your plug-in. I have a web interface setup (KiwiIRC) connected to a IRC network, but I'm having trouble figuring out how to send login info (nickname) to the web interface from your plugin. Could you share any insight? Thanks so much.
                          Last edited by jessekirbs; 03-09-2019, 09:17 PM.

                          Comment


                            Originally posted by jessekirbs View Post
                            getnamo - thanks a million for this plugin. Diving into it now. I'm really interested in using it to communicate with an IRC server to send and retrieve messages. I'm having trouble figuring how how to begin this using your plug-in. I have a web interface setup (KiwiIRC) connected to a IRC network, but I'm having trouble figuring out how to send login info (nickname) to the web interface from your plugin. Could you share any insight? Thanks so much.
                            This plugin connects unreal as a client of a socket.io server, so the best way to setup what you're looking for is to have a socket.io server in say node.js or python which does API calls to your other service (IRC) and forwards them to the unreal clients. (the plugin does support general http requests, but it's not recommended for real-time push services as you'd lose the bidirectionality and ease of use)

                            E.g. if you used a node.js server, you could probably use this npm package https://www.npmjs.com/package/irc, and then pipe the sent/received messages to your client via your desired events

                            just browsing the package, forwarding a message would be something like
                            Code:
                            client.addListener('message', function (from, to, message) {
                                socket.emit('chat message', from + ' => ' + to + ': ' + message);
                            });
                            (see https://github.com/getnamo/socketio-...erver/index.js for a node.js server hosting a basic chat client, socket.on are events that the server receives, socket.emit (or io.emit for multicast) are server send functions)

                            https://github.com/getnamo/socketio-client-ue4-example is a good starting point to understand typical server and client side setup with full sources.
                            Last edited by getnamo; 03-10-2019, 09:32 PM.
                            Plugins: TensorFlow - Socket.io Client - ZipUtility - Leap Motion - Hydra - Myo - RealSense - CIM

                            Comment


                              First,it's awsome.But as a new learner,I got some questions.
                              if I want to use the server to connect to mysql ,how could I use variables in ue4 as parametres to execute sql query?
                              thanks a lot.

                              Comment


                                Originally posted by qiben321456 View Post
                                First,it's awsome.But as a new learner,I got some questions.
                                if I want to use the server to connect to mysql ,how could I use variables in ue4 as parametres to execute sql query?
                                thanks a lot.
                                I'd probably form my query as a blueprint struct with desired parameters, then use the Struct to Json Object to convert it to a json object and emit that to your server. From there you can use the json object to form your sql query. See https://github.com/getnamo/socketio-client-ue4#structs for details on how to formulate complex json objects using structs.
                                Plugins: TensorFlow - Socket.io Client - ZipUtility - Leap Motion - Hydra - Myo - RealSense - CIM

                                Comment

                                Working...
                                X