Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • A AndroidAsync
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 333
    • Issues 333
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 19
    • Merge requests 19
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Koushik Dutta
  • AndroidAsync
  • Issues
  • #379
Closed
Open
Issue created Aug 06, 2015 by Administrator@rootContributor

Websocket server does not completely send large binary payload

Created by: psl8r

There seems to be an issue in which large binary payloads > ~400KB are not fully sent by a websocket server and therefore not received by the client.

Steps to reproduce:

  1. Start a websocket server.

AsyncHttpServer server = new AsyncHttpServer();
server.listen(8000);

server.websocket("/", new AsyncHttpServer.WebSocketRequestCallback() {
    @Override
    public void onConnected(final WebSocket webSocket, AsyncHttpServerRequest request) {

        // TEST: large binary (>400KB) sent from server
        InputStream is = getContext().getResources().openRawResource(R.raw.file1561246251481);
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        int reads;
        try {
            reads = is.read();
            while (reads != -1) {
                baos.write(reads);
                reads = is.read();
            }

            byte[] payload = baos.toByteArray();

            webSocket.send(payload);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
});
  1. Connect from a websocket client and wait to receive
AsyncHttpClient.getDefaultInstance().websocket("http://localhost:8000/", "my-protocol", new WebSocketConnectCallback() {
    @Override
    public void onCompleted(Exception ex, WebSocket webSocket) {
        if (ex != null) {
            ex.printStackTrace();
            return;
        }

        webSocket.setStringCallback(new StringCallback() {
            public void onStringAvailable(String s) {
                System.out.println("I got a string: " + s);
            }
        });
        webSocket.setDataCallback(new DataCallback() {
            public void onDataAvailable(ByteBufferList byteBufferList) {
                System.out.println("I got some bytes!");
                // note that this data has been read
                byteBufferList.recycle();
            }
        });
    }
});

Expected behavior: Receive full binary payload sent by the server.

Actual behavior: Server does not send all the bytes (stepping through using the debugger) and the client DataCallback never fires.

There is actually no issue when sending large binary payloads from a client to the server, only from the server back to the client do I see an issue.

Thanks.

Assignee
Assign to
Time tracking