{"action":"created","issue":{"url":"https://api.github.com/repos/ronf/asyncssh/issues/24","labels_url":"https://api.github.com/repos/ronf/asyncssh/issues/24/labels{/name}","comments_url":"https://api.github.com/repos/ronf/asyncssh/issues/24/comments","events_url":"https://api.github.com/repos/ronf/asyncssh/issues/24/events","html_url":"https://github.com/ronf/asyncssh/issues/24","id":97227172,"number":24,"title":"data should be bytes","user":{"login":"sharow","id":422539,"avatar_url":"https://avatars.githubusercontent.com/u/422539?v=3","gravatar_id":"","url":"https://api.github.com/users/sharow","html_url":"https://github.com/sharow","followers_url":"https://api.github.com/users/sharow/followers","following_url":"https://api.github.com/users/sharow/following{/other_user}","gists_url":"https://api.github.com/users/sharow/gists{/gist_id}","starred_url":"https://api.github.com/users/sharow/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sharow/subscriptions","organizations_url":"https://api.github.com/users/sharow/orgs","repos_url":"https://api.github.com/users/sharow/repos","events_url":"https://api.github.com/users/sharow/events{/privacy}","received_events_url":"https://api.github.com/users/sharow/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-07-25T13:33:16Z","updated_at":"2015-07-26T10:42:49Z","closed_at":null,"body":"Currently `data_received(self, data, datatype)` is giving str,\r\nand it is decoded by `session_encoding`. default is utf-8.\r\nhowever I think data should be bytes or bytearray.\r\n\r\n\r\n### reason 1\r\nfor examaple\r\n\r\n```\r\n# test.py\r\nimport sys\r\nimport random\r\nimport time\r\n\r\ndata = 'あいうえお'.encode('utf-8')\r\n\r\nwhile True:\r\n    r = random.randint(0, len(data))\r\n    sys.stdout.buffer.write(data[:r])\r\n    sys.stdout.buffer.flush()\r\n    time.sleep(0.5)\r\n    sys.stdout.buffer.write(data[r:])\r\n    sys.stdout.buffer.flush()\r\n    sys.stdout.buffer.write(b'\\r\\n')\r\n    sys.stdout.buffer.flush()\r\n```\r\n\r\nserver is https://gist.github.com/sharow/809242c0c12d66d0594f\r\n```\r\n# client run:\r\npython test.py | ssh -o StrictHostKeyChecking=no -p 2200 test@x.x.x.x\r\n```\r\n\r\nand server say\r\n```\r\nSSH connection received from x.x.x.x\r\nあいうえお\r\nあいうえお\r\nあいうえお\r\nあいうえ\r\nException in callback SSHConnection._cleanup(DisconnectErr...ecode error',))\r\nhandle: <Handle SSHConnection._cleanup(DisconnectErr...ecode error',))>\r\nTraceback (most recent call last):\r\n  File \"/usr/lib/python3.4/asyncio/events.py\", line 120, in _run\r\n    self._callback(*self._args)\r\n  File \"/usr/lib/python3.4/site-packages/asyncssh/connection.py\", line 394, in _cleanup\r\n    self._owner.connection_lost(exc)\r\n  File \"simple_server.py\", line 31, in connection_lost\r\n    raise exc\r\n  File \"/usr/lib/python3.4/site-packages/asyncssh/connection.py\", line 473, in data_received\r\n    while self._inpbuf and self._recv_handler():\r\n  File \"/usr/lib/python3.4/site-packages/asyncssh/connection.py\", line 694, in _recv_packet\r\n    processed = self.process_packet(pkttype, packet)\r\n  File \"/usr/lib/python3.4/site-packages/asyncssh/packet.py\", line 161, in process_packet\r\n    self.packet_handlers[pkttype](self, pkttype, packet)\r\n  File \"/usr/lib/python3.4/site-packages/asyncssh/connection.py\", line 1485, in _process_channel_msg\r\n    chan.process_packet(pkttype, packet)\r\n  File \"/usr/lib/python3.4/site-packages/asyncssh/packet.py\", line 161, in process_packet\r\n    self.packet_handlers[pkttype](self, pkttype, packet)\r\n  File \"/usr/lib/python3.4/site-packages/asyncssh/channel.py\", line 329, in _process_data\r\n    self._accept_data(data)\r\n  File \"/usr/lib/python3.4/site-packages/asyncssh/channel.py\", line 229, in _accept_data\r\n    self._deliver_data(data, datatype)\r\n  File \"/usr/lib/python3.4/site-packages/asyncssh/channel.py\", line 201, in _deliver_data\r\n    'Unicode decode error') from None\r\nasyncssh.misc.DisconnectError: Disconnect Error: Unicode decode error\r\n```\r\n\r\npayload is correct utf-8. data is arrived but divided sometime.\r\nthat mean.. session middleware shouldn't care about encoding.\r\n\r\n### reason 2\r\nencoding is depend on client. NOT SSH SEVER.\r\n\r\n\r\n--\r\nalso paramiko channel.recv() is giving byte."},"comment":{"url":"https://api.github.com/repos/ronf/asyncssh/issues/comments/124968714","html_url":"https://github.com/ronf/asyncssh/issues/24#issuecomment-124968714","issue_url":"https://api.github.com/repos/ronf/asyncssh/issues/24","id":124968714,"user":{"login":"sharow","id":422539,"avatar_url":"https://avatars.githubusercontent.com/u/422539?v=3","gravatar_id":"","url":"https://api.github.com/users/sharow","html_url":"https://github.com/sharow","followers_url":"https://api.github.com/users/sharow/followers","following_url":"https://api.github.com/users/sharow/following{/other_user}","gists_url":"https://api.github.com/users/sharow/gists{/gist_id}","starred_url":"https://api.github.com/users/sharow/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sharow/subscriptions","organizations_url":"https://api.github.com/users/sharow/orgs","repos_url":"https://api.github.com/users/sharow/repos","events_url":"https://api.github.com/users/sharow/events{/privacy}","received_events_url":"https://api.github.com/users/sharow/received_events","type":"User","site_admin":false},"created_at":"2015-07-26T10:42:49Z","updated_at":"2015-07-26T10:42:49Z","body":"sorry session_encoding=None is works fine.\r\nit my simple wrong:\r\n```\r\n- self._chan.write('Welcome to SSH server')\r\n+ self._chan.write(b'Welcome to SSH server')\r\n```"}}