Skip to content

Commit

Permalink
Troubleshoot connection error in docker env
Browse files Browse the repository at this point in the history
  • Loading branch information
Dletta committed Dec 31, 2024
1 parent d1a87b6 commit a02d33c
Showing 1 changed file with 38 additions and 32 deletions.
70 changes: 38 additions & 32 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,39 +131,45 @@ senderModule.establishConnection = async function () {
})
} else if (senderModule.transport === 'tcp') {
console.log(`Opening TCP connection to ${senderModule.receiver}:${senderModule.port}`)
senderModule.socket = await Bun.connect({
hostname: senderModule.receiver,
port: senderModule.port,

socket: {
data (data) {
console.log('Received Data')
console.log(data)
},
open (socket) {
resolve(socket)
},
drain (socket) {
console.log('Draining')
try {
senderModule.socket = await Bun.connect({
hostname: senderModule.receiver,
port: senderModule.port,

socket: {
data (data) {
console.log('Received Data')
console.log(data)
},
open (socket) {
console.log('Connection to HEP Server opened')
},
drain (socket) {
console.log('Draining')
},
connectError(_, error) {
console.log('Connection Error')
console.log(error)
reject()
}, // connection failed
end() {
console.log('Connection to HEP Server closed')
senderModule.socket = null
}, // connection closed by server
timeout() {
console.log('Connection to HEP Server timed-out')
senderModule.socket = null
}, // connection timed out
},
connectError(_, error) {
console.log('Connection Error')
console.log(error)
reject()
}, // connection failed
end() {
console.log('Connection to HEP Server closed')
senderModule.socket = null
}, // connection closed by server
timeout() {
console.log('Connection to HEP Server timed-out')
senderModule.socket = null
}, // connection timed out
},
})

senderModule.sendData = function (hepPacket) {
return senderModule.socket.write(hepPacket)
})

senderModule.sendData = function (hepPacket) {
return senderModule.socket.write(hepPacket)
}

} catch (error) {
console.log('Error connecting to HEP Server')
console.log(error)
}

return senderModule.socket
Expand Down

0 comments on commit a02d33c

Please sign in to comment.