Title: ChannelBufferInput blocks until full buffer is read · Issue #426 · msgpack/msgpack-java · GitHub
Open Graph Title: ChannelBufferInput blocks until full buffer is read · Issue #426 · msgpack/msgpack-java
X Title: ChannelBufferInput blocks until full buffer is read · Issue #426 · msgpack/msgpack-java
Description: Please take a look at this sample: import java.net.InetSocketAddress; import java.net.Socket; import java.nio.ByteBuffer; import java.nio.channels.ServerSocketChannel; import java.nio.channels.SocketChannel; import java.util.concurrent.E...
Open Graph Description: Please take a look at this sample: import java.net.InetSocketAddress; import java.net.Socket; import java.nio.ByteBuffer; import java.nio.channels.ServerSocketChannel; import java.nio.channels.Sock...
X Description: Please take a look at this sample: import java.net.InetSocketAddress; import java.net.Socket; import java.nio.ByteBuffer; import java.nio.channels.ServerSocketChannel; import java.nio.channels.Sock...
Opengraph URL: https://github.com/msgpack/msgpack-java/issues/426
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"ChannelBufferInput blocks until full buffer is read","articleBody":"Please take a look at this sample:\r\n```\r\nimport java.net.InetSocketAddress;\r\nimport java.net.Socket;\r\nimport java.nio.ByteBuffer;\r\nimport java.nio.channels.ServerSocketChannel;\r\nimport java.nio.channels.SocketChannel;\r\nimport java.util.concurrent.ExecutorService;\r\nimport java.util.concurrent.Executors;\r\n\r\nimport org.msgpack.core.MessagePack;\r\nimport org.msgpack.core.MessageUnpacker;\r\n\r\npublic class ChannelUnpackerTest {\r\n\tpublic static void main(String[] args) throws Exception {\r\n\t\ttry (ServerSocketChannel serverChannel = ServerSocketChannel.open()) {\r\n\t\t\tserverChannel.socket().bind(new InetSocketAddress(\"localhost\", 7777));\r\n\t\t\tExecutorService pool = Executors.newFixedThreadPool(10);\r\n\t\t\tfor (int i = 0; i \u003c 10; i++) {\r\n\t\t\t\tpool.execute(() -\u003e {\r\n\t\t\t\t\ttry {\r\n\t\t\t\t\t\tSocketChannel channel = serverChannel.accept();\r\n\t\t\t\t\t\tchannel.write(ByteBuffer.wrap(new byte[200]));\r\n\t\t\t\t\t} catch (Exception e) {\r\n\t\t\t\t\t\t//nothing\r\n\t\t\t\t\t}\r\n\t\t\t\t});\r\n\t\t\t}\r\n\r\n\t\t\ttry (Socket socket = new Socket(\"localhost\", 7777)) {\r\n\t\t\t\tMessageUnpacker unpacker = MessagePack.newDefaultUnpacker(socket.getInputStream());\r\n\t\t\t\tunpacker.readPayload(ByteBuffer.allocate(128));\r\n\t\t\t\tSystem.out.println(\"read from socket\");\r\n\t\t\t}\r\n\r\n\t\t\ttry (SocketChannel channel = SocketChannel.open(new InetSocketAddress(\"localhost\", 7777))) {\r\n\t\t\t\tMessageUnpacker unpacker = MessagePack.newDefaultUnpacker(channel);\r\n\t\t\t\tunpacker.readPayload(ByteBuffer.allocate(128));\r\n\t\t\t\tSystem.out.println(\"read from channel\");\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n}\r\n```\r\n\r\nThis sample accepts incoming connection, writes 200 bytes to it and waits indefinitely. Consuming first 128 (that is from my real use case - after establishing connection I need to read servers hello message with fixed size of 128 bytes) via MessageUnpacker created via socket InputStream handles this case just fine, however via SocketCnahhel it blocks.\r\n\r\nChanging the server to write large enough data (e.g. 20000 bytes) leads to filling of MessageUnpackers buffer and it can return first 128 bytes.","author":{"url":"https://github.com/isopov","@type":"Person","name":"isopov"},"datePublished":"2017-06-20T08:36:20.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":2},"url":"https://github.com/426/msgpack-java/issues/426"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:53758a77-540d-4002-6ff2-1a93965ff9e4 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | AA3C:1A082:897677:C86E42:6A579251 |
| html-safe-nonce | fab1c69907c063a5d9e0c579d1d315f2ba675612e6300ade5414224e29eaea1f |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBQTNDOjFBMDgyOjg5NzY3NzpDODZFNDI6NkE1NzkyNTEiLCJ2aXNpdG9yX2lkIjoiODQ0NjU4MjA4ODgyMDgyMjYwOSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 68dcd50803679f571204bcd007d8753782ca58ce6ddc588a04d13f8130ebef72 |
| hovercard-subject-tag | issue:237133093 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/msgpack/msgpack-java/426/issue_layout |
| twitter:image | https://opengraph.githubassets.com/ef8bcfd0b92a3b1283d4646d0b9b20ec3550ca6271d868bc22d5f2e54db16431/msgpack/msgpack-java/issues/426 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/ef8bcfd0b92a3b1283d4646d0b9b20ec3550ca6271d868bc22d5f2e54db16431/msgpack/msgpack-java/issues/426 |
| og:image:alt | Please take a look at this sample: import java.net.InetSocketAddress; import java.net.Socket; import java.nio.ByteBuffer; import java.nio.channels.ServerSocketChannel; import java.nio.channels.Sock... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | isopov |
| hostname | github.com |
| expected-hostname | github.com |
| None | a87fc68e9bdf22e1c7e48ac6a60b98882f4bb103314b3f26b3460c61fc5441ae |
| turbo-cache-control | no-preview |
| go-import | github.com/msgpack/msgpack-java git https://github.com/msgpack/msgpack-java.git |
| octolytics-dimension-user_id | 198264 |
| octolytics-dimension-user_login | msgpack |
| octolytics-dimension-repository_id | 1971346 |
| octolytics-dimension-repository_nwo | msgpack/msgpack-java |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 1971346 |
| octolytics-dimension-repository_network_root_nwo | msgpack/msgpack-java |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | a2198d0212ed703af207673eb4d0868d4f867a5b |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width