Browse Source

add milvus-client-id as the query of the socket connection (#683)

Signed-off-by: ryjiang <jiangruiyi@gmail.com>
ryjiang 8 months ago
parent
commit
33d067eb3a
2 changed files with 4 additions and 5 deletions
  1. 3 4
      client/src/context/Data.tsx
  2. 1 1
      server/src/socket.ts

+ 3 - 4
client/src/context/Data.tsx

@@ -412,12 +412,11 @@ export const DataProvider = (props: { children: React.ReactNode }) => {
 
       const extraHeaders = {
         'milvus-client-id': clientId,
-        'x-attu-database': authReq.database,
       };
 
-      socket.current = isElectron
-        ? io(url as string, { extraHeaders })
-        : io({ extraHeaders });
+      const ioParams = { extraHeaders, query: extraHeaders };
+
+      socket.current = isElectron ? io(url as string, ioParams) : io(ioParams);
 
       socket.current.on('connect', async () => {
         // console.info('--- ws connected ---', clientId);

+ 1 - 1
server/src/socket.ts

@@ -16,7 +16,7 @@ export function initWebSocket(server: http.Server) {
   });
 
   io.on('connection', (socket: Socket) => {
-    const clientId = socket.handshake.headers['milvus-client-id'] as string;
+    const clientId = socket.handshake.query['milvus-client-id'] as string;
 
     if (clientId) {
       clients.set(clientId, socket);