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

Errors with bytes as strings in python3 #49

Closed
jskinn opened this Issue Feb 17, 2017 · 11 comments

Comments

Projects
None yet
6 participants
@jskinn

jskinn commented Feb 17, 2017

The current client version installed with pip does not work with python 3.
It's close, the only issue is the use of strings as byte arrays.

This can be solved by changing __init__.py as follows, which work for both python3.4 and python 2.7 (I tested on 3.4.3 and 2.7.6):
line 73:
payload = b""
line 87:
return payload.decode('UTF-8')
line 109:
wfile.write(payload.encode('UTF-8'))

This has the added benefit of ensuring the character encoding is the same in both client and server code.

Thanks.

@qiuwch

This comment has been minimized.

Member

qiuwch commented Feb 17, 2017

Thanks very much. I will update it as you suggested.

@revilokeb

This comment has been minimized.

revilokeb commented Mar 28, 2017

@qiuwch @jskinn I am on Anaconda 3.5.2 on Win, did not install via pip, changed init.py as above and then python3 setup.py install.

I can connect to the server (client.isconnected() == True), but then I am running always into timeout (ERROR:init:317:Can not receive a response from server, timeout after 5.00 seconds) when requesting from server (i.e. e.g. filename = client.request('vget /camera/0/lit') ).

My questions:

  1. Any idea what could be wrong?
  2. Is it possible to easily set server (in this case RealisticRendering on Windows) to listen on different port than 9000?
@revilokeb

This comment has been minimized.

revilokeb commented Mar 28, 2017

Ok I found server logs (RealisticRendering-Win64-65d6144-171cd97\WindowsNoEditor\RealisticRendering\Saved\Logs) and the following lines seem to indicate that port 9000 might indeed be already in use:

FTcpSocketBuilder: Failed to create the socket FTcpListener server as configured
LogTemp:Error: Can not start listening on port 9000, Port might be in use

So I guess I need to find a way to make the server listen on another port.

@revilokeb

This comment has been minimized.

revilokeb commented Mar 28, 2017

I have been running netstat -ab | more and now there is no conflict on port 9000 anymore, so problem solved and I can access the server from python3.

To try answering my own question if port on the server side can be easily set to something else: it doesn't seem so, it seems that port is hard coded (alongside image resolution 640x480) into constructor unrealcv\Source\UnrealCV\Public\ServerConfig.h.

@revilokeb

This comment has been minimized.

revilokeb commented Mar 28, 2017

My above statement about port is not true, see #35. Sorry for having cluttered this thread a bit.

@ahtsan

This comment has been minimized.

ahtsan commented Oct 10, 2017

@jskinn Hello, did you try to get image? For me, normal string works after your modification, but image data doesn't work.

@jskinn

This comment has been minimized.

jskinn commented Oct 23, 2017

I have tried, and my get image doesn't work either. These modifications were suggested before get image was available in the API.
The problem is that in python2, both strings and images are sent back from Unreal as bytes, and you the user somehow know which is which. In python3, the strings are unicode, and the images are not, which means they need different handling.
I don't have a clean fix, because I can't see a good way of distinguishing between string messages and binary messages from the server. This means it needs a more complex internal messaging protocol that supports different message types robustly.
I'm just getting by without get image at the moment.

@qiuwch

This comment has been minimized.

Member

qiuwch commented Oct 23, 2017

Hi, @jskinn @ahtsan . Python 3 support is fixed in this pull request #65, thanks to @befelix .
It has been merged to the master branch and has been pushed to pypi yesterday.
Can you try pip install -U unrealcv and test again? Thanks.

@jeffreykxiao

This comment has been minimized.

jeffreykxiao commented Oct 24, 2017

@qiuwch I'm not the original poster, but I ran into the same issue a while back and fixed it with a stopgap as well. After reinstalling unrealcv with your command, I am having no issues. Thanks for the assistance!

@doublerebel

This comment has been minimized.

doublerebel commented Dec 19, 2017

With the fix from #65, and multiple reports of unrealcv working with python3, I think this issue can be closed.

@jskinn

This comment has been minimized.

jskinn commented Feb 9, 2018

Yep, can confirm it works for me now in python 3. Thanks

@jskinn jskinn closed this Feb 9, 2018

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