Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backgrounding wscat #130

Open
pieterhouwen opened this issue Mar 25, 2021 · 1 comment
Open

Backgrounding wscat #130

pieterhouwen opened this issue Mar 25, 2021 · 1 comment

Comments

@pieterhouwen
Copy link

When I use wscat -c wss://socket.domain.tld/api --auth someuser:somepassword it works perfectly as long as I keep the program on the foreground. But as soon as I try to background it either using nohup or & the wscat crashes. How can I fix this?

The error that I'm getting is this one:

events.js:174
      throw er; // Unhandled 'error' event
      ^

Error: EBADF: bad file descriptor, read
Emitted 'error' event at:
    at lazyFs.read (internal/fs/streams.js:165:12)
    at FSReqWrap.wrapper [as oncomplete] (fs.js:467:17)
@salunkhs
Copy link

salunkhs commented Feb 8, 2024

Dear Team,

I'm currently encountering an issue with the execution of a Bash script within a GitHub workflow. The script is intended to make a WebSocket request using wscat. Here's the relevant snippet of the script:

#!/bin/bash

# Function to run WebSocket request
function runWebSocketTest() {
  local alert=$1
  local url="wss://localhost/api/core/v1/alerts/incoming?api_key=${API_KEY}"
  wscat --no-check -c "$url" -x "$alert"
}

function getTriggeredAlertsCount() {
  local count=$(docker exec postgres-1 psql -U test -d testdb -t -c "SELECT COUNT(*) FROM public.alerts;")
  echo "$count"
}

runWebSocketTest "$ALERT_1"
runWebSocketTest "$ALERT_1"

count=$(getTriggeredAlertsCount)
echo "Triggered alerts count: $count"

When I run this script manually on the GitHub runner, the wscat command executes properly and inserts an alert into the database. However, when the same script is executed from the GitHub workflow, it seems that the wscat command does not execute, resulting in no data being inserted into the database.

Upon investigation, it appears that the GitHub workflow runs this script in the background, potentially causing the wscat command not to execute as expected.

I would appreciate any suggestions or insights on how to resolve this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants