socketio / socketio/socket.io

authToken = null in springboot despite set by the client

Open
#4,972 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

question
Dominant language
TypeScript
Stars
63.2k
Forks
10.3k
Avg merge
11d 20h
Merged PRs (30d)
2

Description

Describe the bug
Im setting up the server in my springboot application and nodejs application (not simaltaneously) both and my client in nodejs.
When I set the auth token on my client(in node application) and server is also in node it works fine and the authToken object is found in the handshake but if I run the server in my springboot application, authToken object is null.

To Reproduce

Please fill the following code example:

Server

socketIOServer.addConnectListener(new ConnectListener() {
            @Override
            public void onConnect(SocketIOClient client) {
                Object jwtToken = client.getHandshakeData().getAuthToken();  // null here
            }
}

Socket.IO client version: x.y.z

Client

const io = require('socket.io-client');

// Connect to the server with custom headers
const socket = io('http://localhost:8081', {
    auth: {token: 'eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiIxMjM0LGpvaG5kb2VAZXhhbXBsZS5jb20iLCJpYX' },
});


// Handle connection event
socket.on('connect', () => {
  console.log('Connected to server');
});

// Handle custom events from the server
socket.on('message', (data) => {
  console.log('Received message from server:', data);
});

// Emit custom events to the server
socket.emit('chatMessage', 'Hello, server!');

Expected behavior
Expect springboot tocatch the authToken in handshake

Platform:
-MacOs

Additional context
Query params when set are being properly found in url params of the handshake, but authtoken isnt

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the Spring Boot connect listener and the Node.js client's io auth option, then compare how the handshake data is handled on each server implementation. The issue is resolved when the token sent in auth is available through the Spring Boot server's handshake data, with the relevant client and server versions documented.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, nodejs, spring-boot
Domain
api, authentication, backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
28/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.