Skip to content

When Cocos Creator builds a WeChat mini-game, it cannot connect to the WebSocket server #161

@jtby

Description

@jtby

Cocos Creator 3.8.7
Colyseus 0.16.9

When Cocos Creator builds a WeChat mini-game, it cannot connect to the WebSocket server

    async connect() {
        try {
            console.log("connecting to Colyseus..."); // console have this log
            this.room = await this.client.joinOrCreate("my_room");

            console.log("joined successfully!"); // console not this log 
            console.log("user's sessionId:", this.room.sessionId);

            this.room.onStateChange((state) => {
                console.log("onStateChange: ", state);
            });

            this.room.onLeave((code) => {
                console.log("onLeave:", code);
            });

        } catch (e) {
            console.error("Error connecting to Colyseus:", e);
        }
    }
Image

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