Skip to content

[error] consume error: websocketpp.processor:9 (Invalid use of reserved bits) #384

Open
@8Observer8

Description

@8Observer8

I tried to connect locally but got this error:

OpenGL Version: 3.1.0 - Build 9.17.10.4459
[2023-01-05 13:27:08] [connect] Successful connection
[2023-01-05 13:27:08] [connect] WebSocket Connection 127.0.0.1:3000 v-2 "WebSocket++/0.8.2" /socket.io/?EIO=3&transport=websocket&t=1672910828 101
[2023-01-05 13:27:08] [error] consume error: websocketpp.processor:9 (Invalid use of reserved bits)
[2023-01-05 13:27:08] [disconnect] Disconnect close local:[1002,Invalid use of reserved bits] remote:[1006]
[2023-01-05 13:27:13] [connect] Successful connection
[2023-01-05 13:27:13] [connect] WebSocket Connection 127.0.0.1:3000 v-2 "WebSocket++/0.8.2" /socket.io/?EIO=3&transport=websocket&t=1672910833 101
[2023-01-05 13:27:13] [error] consume error: websocketpp.processor:9 (Invalid use of reserved bits)
[2023-01-05 13:27:13] [disconnect] Disconnect close local:[1002,Invalid use of reserved bits] remote:[1006]

main.cpp

#include <glad/glad.h>
#include <iostream>

#define SDL_MAIN_HANDLED
#include <SDL2/SDL.h>

#define SIO_TLS
#include <sio_client.h>

const int WIDTH = 400, HEIGHT = 400;
const float maxFPS = 60.f;

int main()
{
    // Init SDL2
    if (SDL_Init(SDL_INIT_VIDEO) < 0)
    {
        std::cout << SDL_GetError << std::endl;
        exit(EXIT_FAILURE);
    }

    SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);

    SDL_Window *window = SDL_CreateWindow("CG_P4", SDL_WINDOWPOS_CENTERED,
        SDL_WINDOWPOS_CENTERED, WIDTH, HEIGHT, SDL_WINDOW_OPENGL);
    if (!window)
    {
        std::cout << SDL_GetError << std::endl;
        SDL_Quit();
        exit(EXIT_FAILURE);
    }

    SDL_GLContext glContext = SDL_GL_CreateContext(window);
    if (!glContext)
    {
        std::cout << SDL_GetError << std::endl;
        SDL_Quit();
        exit(EXIT_FAILURE);
    }

    // Initialize GLAD to set up the OpenGL Function pointers
    if (!gladLoadGL())
    {
        std::cout << "Failed to initialize the GLAD library" << std::endl;
        SDL_Quit();
        exit(EXIT_FAILURE);
    }

    std::cout << "OpenGL Version: " << glGetString(GL_VERSION) << std::endl;

    // Set background color
    glClearColor(0.875f, 0.875f, 0.875f, 0.f);

    // Define the viewport dimensions
    glViewport(0, 0, WIDTH, HEIGHT);

    sio::client h;
    h.connect("https://127.0.0.1:3000");
    // h.connect("wss://connection-js.onrender.com/");
    // h.connect("wss://hungry-mighty-hospital.glitch.me");

    bool running = true;
    while (running)
    {
        SDL_Event event;

        while (SDL_PollEvent(&event))
        {
            switch (event.type)
            {
                case SDL_QUIT:
                    running = false;
                    break;
            }
        }
        float startTicks = SDL_GetTicks();

        glClear(GL_COLOR_BUFFER_BIT);

        SDL_GL_SwapWindow(window);

        // Limit FPS to the max FPS
        float frameTicks = SDL_GetTicks() - startTicks;
        if (1000.f / maxFPS > frameTicks)
        {
            SDL_Delay(1000.f / maxFPS - frameTicks);
        }
    }

    return 0;
}

app.js:

const express = require("express");
const io = require("socket.io")();
const http = require("http");
const path = require("path");

const app = express();
app.use(express.static(path.join(process.cwd(), "public")));
const httpServer = http.createServer(app);

const port = process.env.PORT || 3000;
httpServer.listen(port, () => console.log("Listening at port: " + port));
const sio = io.listen(httpServer);

sio.sockets.on("connection", (socket) => {
    console.log("client was connected");
});

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