Skip to content

websocket-chat logical problem #8

Open
@joyhope

Description

@joyhope

Simple run the demo, it works, but the flow has problem.

func (c *Client) listenRead() the api is never exited, always blocked on the c.doneCh on the second time

        err := websocket.JSON.Receive(c.ws, &msg)
        if err == io.EOF {
            c.doneCh <- true   <<==

After first c.doneCh <-true is send, the select will immediate run default flow. The Receive will get io.EOF again, but at that time, the listenWrite is exit because of c.donCh. The c.doneCh is not buffered, so it will be blocked for ever.

The simple fix is add time.Sleep(xxx) after the c.doneCh <-true. (Any way it is not a good fix.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions