# ue 5.0 python and socket.io in Editor issue

**URL:** <https://forums.unrealengine.com/t/ue-5-0-python-and-socket-io-in-editor-issue/840536>\
**Category:** Programming & Scripting\
**Tags:** Python, socket, threading, unreal-engine, question\
**Created:** [April 3, 2023, 3:23pm UTC](https://forums.unrealengine.com/t/ue-5-0-python-and-socket-io-in-editor-issue/840536 "2023-04-03T15:23:41Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![sinokgr1](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@sinokgr1](https://forums.unrealengine.com/u/sinokgr1)\
**Post date:** [April 3, 2023, 3:23pm UTC](https://forums.unrealengine.com/t/ue-5-0-python-and-socket-io-in-editor-issue/840536/1 "2023-04-03T15:23:41Z")

</div>

Hi everyone,

I’m trying to create a small Python script for in Editor use, where I can send commands from a [socket.io](http://socket.io) server to UE using Python.

It connects fine, Unreal is logging the messages, but because apparently [socket.io](http://socket.io) is running on a different thread, I’m getting an error saying

> LogUtils: Error: You are not on the main thread.

I remember that I had a similar issue in the past, with 3ds Max, and a developer from Autodesk created [this example](https://github.com/ADN-DevTech/3dsMax-Python-HowTos/tree/master/src/packages/socketioclient) where he was using a [mxthread](https://github.com/ADN-DevTech/3dsMax-Python-HowTos/tree/master/src/packages/mxthread) module to force the code run on the main thread but I’m not sure how this can be used with Unreal.

This is the python code

```Python
import socketio
import unreal

# Create a Socket.IO client instance
sio = socketio.Client()

# Define event handlers
@sio.event
def connect():
    print('Connected to server')

@sio.event
def disconnect():
    print('Disconnected from server')

@sio.event
def message(data):
    print('Received message:', data)
    actors = unreal.EditorLevelLibrary.get_all_level_actors()
    for actor in actors:
        print(actor.get_actor_label())

# Connect to the server
sio.connect('http://localhost:3210')

```

and this is the Output log

> LogPython: Connected to server  
> LogPython: Received message:  
> LogPython: Hi from the server  
> LogPython: Warning: W:/190205\_Renderapp\_RnD/build/CarConfigurator/Content/RenderappAssets/test.py:19: DeprecationWarning: EditorLevelLibrary: Function ‘get\_all\_level\_actors’ on ‘EditorLevelLibrary’ is deprecated: The Editor Scripting Utilities Plugin is deprecated - Use the function in Editor Actor Utilities Subsystem  
> actors = unreal.EditorLevelLibrary.get\_all\_level\_actors()  
> LogUtils: Error: You are not on the main thread.

Any help would be more than appreciated.

Nick
