Skip to content

Commit

Permalink
Fix the handshake issue.
Browse files Browse the repository at this point in the history
  • Loading branch information
proAlexandr committed Aug 14, 2019
1 parent 53b7c35 commit 7aeb970
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "kube-forwarder",
"version": "1.5.0",
"version": "1.5.1",
"author": "Pixel Point <[email protected]>",
"homepage": "https://kube-forwarder.poxelpoint.io",
"description": "A tool for managing port forwarding configs for kubernetes clusters",
Expand Down
11 changes: 9 additions & 2 deletions src/renderer/lib/k8s-port-forwarding-patch.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import querystring from 'querystring'
import { WebSocketHandler } from '@kubernetes/client-node/dist/web-socket-handler'
import WebSocket from 'isomorphic-ws'

WebSocketHandler.restartableHandleStandardInput = function (createWS, stdin, streamNum = 0) {
WebSocketHandler.restartableHandleStandardInput = async function (createWS, stdin, streamNum = 0) {
const tryLimit = 3;
let queue = Promise.resolve()
let ws = null
Expand Down Expand Up @@ -49,6 +49,13 @@ WebSocketHandler.restartableHandleStandardInput = function (createWS, stdin, str
ws.close();
}
});

// It's important to open connection immediately (even without data) for some apps (for example: mariadb)
try {
ws = await createWS()
} catch (e) {
console.error(e)
}
}

export function patchForward (forward) {
Expand All @@ -72,7 +79,7 @@ export function patchForward (forward) {
needsToReadPortNumber[index * 2 + 1] = true
})

return await this.handler.connect(path, null, (streamNum, buff) => {
return this.handler.connect(path, null, (streamNum, buff) => {
if (streamNum >= targetPorts.length * 2) {
return !this.disconnectOnErr
}
Expand Down

0 comments on commit 7aeb970

Please sign in to comment.