Xpra: Ticket #424: Invalid packet format

I am running linuxmint olivia amd64 and have a try xpra for a first time. apt-get install xpra installs me 0.10.1 version.

According to minimal instructions on first console i try to run

xpra start :100 --start-child=xterm --no-daemon --no-notifications --no-pulseaudio

and xpra attach :100 on second console that quickly ends with

xpra attach :100
xpra client version 0.10.1
2013-08-29 10:30:58,477 No OpenGL_accelerate module loaded: No module named OpenGL_accelerate
2013-08-29 10:30:58,635 OpenGL Version: 3.3.0 NVIDIA 313.30
2013-08-29 10:30:58,659 GL Extension GL_ARB_shader_objects available
2013-08-29 10:30:58,683 GL Extension GL_ARB_framebuffer_object available
2013-08-29 10:30:58,685 GL Extension GL_ARB_fragment_program available
2013-08-29 10:30:58,686 GL Extension GL_ARB_texture_rectangle available
2013-08-29 10:30:58,686 GL Extension GL_ARB_vertex_program available
2013-08-29 10:30:58,876 server requested disconnect: invalid packet format
2013-08-29 10:30:58,877 connection closed after 1 packets received (55 bytes) and 1 packets sent (25K bytes)
2013-08-29 10:30:58,978 Connection lost

on a server side i see an exception

2013-08-29 10:30:58,208 New connection received: SocketConnection(/home/kot/.xpra/volkovav-100)
Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/xpra/net/bencode.py", line 72, in bdecode
    r, l = decode_func[x[0]](x, 0)
  File "/usr/lib/python2.7/dist-packages/xpra/net/bencode.py", line 45, in decode_list
    v, f = decode_func[x[f]](x, f)
  File "/usr/lib/python2.7/dist-packages/xpra/net/bencode.py", line 57, in decode_dict
    r[k], f = decode_func[x[f]](x, f)
IndexError: string index out of range
2013-08-29 10:30:58,845 value error reading packet:
Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/xpra/net/protocol.py", line 641, in do_read_parse_thread_loop
    packet, l = bdecode(data)
  File "/usr/lib/python2.7/dist-packages/xpra/net/bencode.py", line 76, in bdecode
    raise ValueError
ValueError

full log in attachment



Thu, 29 Aug 2013 06:34:27 GMT - Alexei Volkov: attachment set

xpra start log


Thu, 29 Aug 2013 06:44:23 GMT - Antoine Martin: owner, status, description changed; milestone set

Hmmm, that's going to be difficult to diagnose. Somehow the initial packet gets encoded but fails to decode.. And since logging network packets was slowing things down too much, I have removed it. So, to see the actual packet contents, you will have to use "-z 0" to turn off decompression, connect to a tcp socket ("xpra start --bind-tcp" + "xpra attach tcp:HOST:port") and use tcpdump or ngrep to capture it.

The encoder code has not changed at all in a very long time. But the amount of data we include in the hello packet has, so downgrading to 0.9.x may help.


Thu, 29 Aug 2013 06:55:56 GMT - Alexei Volkov: attachment set

tcpdump log


Thu, 29 Aug 2013 06:56:30 GMT - Alexei Volkov:

ok.

xpra start :100 --start-child=xterm --no-daemon --no-notifications --no-pulseaudio -z 0 --bind-tcp 127.0.0.1:8888
xpra attach tcp:127.0.0.1:8888
tcpdump -w /tmp/xpra.pcap -s 2048 -i lo port 8888

and xpra.pcap​ in attachment


Thu, 29 Aug 2013 06:59:22 GMT - Antoine Martin:

(only just saw your tcpdump as I was writing this) I've tried reproducing the bug using the packet string from the bug, but the packet string sample isn't long enough:

s = "l5:hellod7:aliasesd4:belli11e9:challengei14e27:configure-override-redirecti7e15:connection-"+
    "losti22e6:cursori16e12:desktop_sizei12e10:disconnecti9e4:drawi8e9:gibberishi24e5:helloi15e13:info-
    "responsei2e11:lost-windowi6e21:new-override-redirecti13e8:new-trayi25e10:new-"+
    "windowi23e12:notify_closei10e11:notify_showi20e4:pingi3e9:ping_echoi5e11:set_deflatei18e10:sound-"+
    "datai1e16:startup-completei21e11:window-iconi26e15:window-metadatai19e14:window-"+
    "resizedi17ee18:auto_refresh_delayi250e4:belli1e9:build.bit5:64bit8:build.by8:buildbot9:build.cpu6:"+
    "x86_6410:build.date10:2013-08-2025:build.local_modifications1:08:build.on13:winswitch.org14"+
    ":build.revision4:419119:chunked_compressioni1e11:client_type11:Python/Gtk29:clipboardi1e16:"+
    "clipboard.greedyi0e23:clipboard.notificationsi1e22:clipboard.want_targetsi0e20:compressible_cursorsi1e7:"+
    "cursorsi1e12:desktop_sizeli1920ei1080ee3:dpii96e20:encoding.PIL.version5:1.1.724:encoding.avcodec.version11"+
    ":Lavc53.35.023:encoding.client_optionsi1e18:encoding.csc_atomsi1e18:encoding.csc_modesl7:YUV420P7:YUV422P7:"+
    "YUV444P4:BGRA4:BGRXe24:encoding.initial_qualityi50e20:encoding.min-qualityi50e18:encoding.min-speedi0e18:"+
    "encoding.rgb24zlibi1e23:encoding.supports_deltal3:png5:rgb245:rgb32e24:encoding.swscale.version8:SwS2.1.021:"+
    "encoding.transparencyi1e21:encoding.uses_swscalei1e22:encoding.video_scalingi1e20:encoding.vpx.versioni3e21:"+
    "encoding.webp.version5:0.2.226:encoding.x264.I420.profile6:high1029:encoding.x264.YUV420P.profile6:high1021:"+
    "encoding.x264.versioni123e23:encoding_client_optionsi1e9:encodingsl4:x2643:vpx4:webp3:png5:png/P5:png/L3:rgb4:jpege14:"+
    "encodings.corel5:rgb243:vpx4:x2644:webp3:png5:png/L5:png/P4:jpeg5:rgb32e21:encodings.rgb_formatsl3:RGB4:RGBAe21:"+
    "generic-rgb-encodingsi1e20:generic_window_typesi1e11:gtk.versionli2ei24ei17ee8:hostname8:volkovav10:key_repeatli500ei30ee13:"+
    "keyboard_synci1e9:mmap_file21:/tmp/xpra.3zOs4t.mmap10:mmap_tokeni244925642224448813989947185054562865453e9:"+
    "modifiersle4:name27:\xd0\x90\xd0\xbb\xd0\xb5\xd0\xba\xd1\x81\xd0\xb5\xd0\xb9 \xd0\x92\xd0\xbe\xd0\xbb\xd0\xba\xd0\xbe\xd0\xb213:"+
    "named_cursorsi1e9:namespacei1e13:notificationsi1e23:notify-startup-completei1e8:platform6:linux216:platform.machine6:"+
    "x86_6418:platform.processor6:x86_6416:platform.release16:3.8.0-19-generic13:pygtk.versionli2ei24ei0ee14:"+
    "python.versionli2ei7ei4ee12:randr_notifyi1e11:raw_packetsi1e16:raw_window_iconsi1e7:rencodei1e15:"+
    "rencode.version5:1.0.29:rgb24zlibi1e12:screen_sizesll4::0.0i1920ei1080ei483ei272ell7:"+
    "DVI-I-1i0ei0ei1920ei1080ei477ei268eeei0ei0ei1920ei1055eee20:server-window-resizei1e11:"+
    "server_uuid0:5:sharei0e14:sound.decodersl3:mp37:wavpack3:wav4:flac5:speexe14:"+
    "sound.encodersl3:mp37:wavpack3:wav4:flac5:speexe17:sound.gst.versionli0ei10ei36ee19:"+
    "sound.pulseaudio.id42:1000@2f6a9045c2bc8db6bf32b2d7517969bf/250423:sound.pulseaudio.server65:"+
    "{2f6a9045c2bc8db6bf32b2d7517969bf}unix:/run/user/kot/pulse/native19:sound.pygst.versionli0ei10ei22ee13:"+
    "sound.receivei1e10:sound.sendi1e11:system_trayi1e8:username3:kot4:uuid40:1b63a015423d830f6fc37"
from xpra.net.bencode import bdecode
bdecode(s)

Thu, 29 Aug 2013 07:03:59 GMT - Antoine Martin:

Python and strings is a terrible mess...

I suspect that this has something to do with unicode characters in the hello packet, can you try temporarily setting your name (as found in /etc/passwd to a pure ascii string instead? Or even just as a newly created test user (say "test"). And anything else in your `env` that has non-ascii characters. Does this fix things?


Thu, 29 Aug 2013 07:15:58 GMT - Alexei Volkov:

I have changed user name to latin only chars and it fixes an issue. Is it possible to override it with some environment variable instead of changing username in /etc/passwd ?


Thu, 29 Aug 2013 07:29:46 GMT - Antoine Martin:

Is it possible to override it with some environment variable instead of changing username in /etc/passwd ?


No, we get it from the system's pwd API. But I will cook up a fix today and release 0.10.2


Thu, 29 Aug 2013 07:31:54 GMT - Alexei Volkov:

Thanks in advance!


Thu, 29 Aug 2013 08:14:54 GMT - Antoine Martin:

I had done some work already on strings and unicode to try to revive the python3/gtk3 client support, see r4205, r4206, r4207 and r4209 (it was a bit messy as I messed up the commits..)

r4237 works for me even after changing my name in /etc/passwd

If you can, please confirm that r4237 (for trunk) or (r4238 for v0.10.x branch) fixes things for you too. I will release 0.10.2 with the fix asap.

What is odd is that I get a different error from the one you posted, mine is client side:

error in write format loop
Traceback (most recent call last):
  File "/usr/lib64/python2.7/site-packages/xpra/net/protocol.py", line 270, in _write_format_thread_loop
    self._add_packet_to_queue(*self._get_packet_cb())
  File "/usr/lib64/python2.7/site-packages/xpra/net/protocol.py", line 280, in _add_packet_to_queue
    chunks, proto_flags = self.encode(packet)
  File "/usr/lib64/python2.7/site-packages/xpra/net/protocol.py", line 424, in encode
    data = zcompress(main_packet, level)
  File "/usr/lib64/python2.7/site-packages/xpra/net/protocol.py", line 54, in zcompress
    return compress(packet, level)
UnicodeEncodeError: 'ascii' codec can't encode characters in position 276-282: ordinal not in range(128)
connection lost: error in network packet write/format: 'ascii' codec can't encode characters in position 276-282: ordinal not in range(128)
connection closed after 0 packets received (0.0 bytes) and 0 packets sent (0.0 bytes)
Connection lost

Even without compression (-z 0):

error in write format loop
Traceback (most recent call last):
  File "/usr/lib64/python2.7/site-packages/xpra/net/protocol.py", line 270, in _write_format_thread_loop
    self._add_packet_to_queue(*self._get_packet_cb())
  File "/usr/lib64/python2.7/site-packages/xpra/net/protocol.py", line 284, in _add_packet_to_queue
    self._add_chunks_to_queue(chunks, proto_flags, start_send_cb, end_send_cb)
  File "/usr/lib64/python2.7/site-packages/xpra/net/protocol.py", line 317, in _add_chunks_to_queue
    data = str(data)
UnicodeEncodeError: 'ascii' codec can't encode characters in position 276-282: ordinal not in range(128)
connection lost: error in network packet write/format: 'ascii' codec can't encode characters in position 276-282: ordinal not in range(128)
connection closed after 0 packets received (0.0 bytes) and 0 packets sent (0.0 bytes)
Connection lost

Thu, 29 Aug 2013 08:44:19 GMT - Alexei Volkov:

I confirm it works now just fine.


Thu, 29 Aug 2013 08:51:58 GMT - Antoine Martin: status changed; resolution set

Closing. Thanks for your help!

v0.10.2 has been released with the fix, it is available in binary packages will follow shortly.


Sat, 23 Jan 2021 04:55:03 GMT - migration script:

this ticket has been moved to: https://github.com/Xpra-org/xpra/issues/424