empiricaly / empirica

Open source project to tackle the problem of long development cycles required to produce software to conduct multi-participant and real-time human experiments online.
https://empirica.ly/
Apache License 2.0
45 stars 8 forks source link

Error in starting empirica server with existing tajriba.json file #560

Open devonrojas opened 4 months ago

devonrojas commented 4 months ago

Is there an existing issue for this?

What happened?

When going to serve my bundled empirica project (after the first initial serve), I get a "connection refused" error on port 3000 that prevents the empirica server from starting correctly. However, after some time, the server is able to run successfully. I have verified that there are no other processes using port 3000 at the time of running the command.

The only solution I've found is to delete the tajriba.json file and do a fresh start of the server.

Steps To Reproduce

  1. Bundle empirica project using empirica bundle
  2. Serve project using empirica serve
  3. Run a batch of game(s)
  4. Close server
  5. Restart server using empirica serve

Empirica Version

Version: v1.11.2
SHA:     0cf63f4
Build:   216
Branch:  main
Time:    2024-04-21T05:45:28Z

Client:  1.11.2
Server:  1.11.2

What OS are you seeing the problem on?

Linux

What browser are you seeing the problem on?

Does not apply

Relevant log output

22:08:18.554 ERR connection error Ds {
  [Symbol(kTarget)]: ye {
    _events: [Object: null prototype] {
      error: [Function],
      close: [Function],
      open: [Function],
      message: [Function]
    },
    _eventsCount: 4,
    _maxListeners: undefined,
    _binaryType: 'nodebuffer',
    _closeCode: 1006,
    _closeFrameReceived: false,
    _closeFrameSent: false,
    _closeMessage: <Buffer >,
    _closeTimer: null,
    _extensions: {},
    _paused: false,
    _protocol: '',
    _readyState: 2,
    _receiver: null,
    _sender: null,
    _socket: null,
    _bufferedAmount: 0,
    _isServer: false,
    _redirects: 0,
    _autoPong: true,
    _url: 'ws://localhost:3000/query',
    _req: null,
    [Symbol(kCapture)]: false
  },
  [Symbol(kType)]: 'error',
  [Symbol(kError)]: Error: connect ECONNREFUSED 127.0.0.1:3000
      at __node_internal_captureLargerStackTrace (node:internal/errors:477:5)
      at __node_internal_exceptionWithHostPort (node:internal/errors:655:12)
      at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1247:16) {
    errno: -111,
    code: 'ECONNREFUSED',
    syscall: 'connect',
    address: '127.0.0.1',
    port: 3000
  },
  [Symbol(kMessage)]: 'connect ECONNREFUSED 127.0.0.1:3000'
}
22:08:20.219 ERR connection error Ds {
  [Symbol(kTarget)]: ye {
    _events: [Object: null prototype] {
      error: [Function],
      close: [Function],
      open: [Function],
      message: [Function]
    },
    _eventsCount: 4,
    _maxListeners: undefined,
    _binaryType: 'nodebuffer',
    _closeCode: 1006,
    _closeFrameReceived: false,
    _closeFrameSent: false,
    _closeMessage: <Buffer >,
    _closeTimer: null,
    _extensions: {},
    _paused: false,
    _protocol: '',
    _readyState: 2,
    _receiver: null,
    _sender: null,
    _socket: null,
    _bufferedAmount: 0,
    _isServer: false,
    _redirects: 0,
    _autoPong: true,
    _url: 'ws://localhost:3000/query',
    _req: null,
    [Symbol(kCapture)]: false
  },
  [Symbol(kType)]: 'error',
  [Symbol(kError)]: Error: connect ECONNREFUSED 127.0.0.1:3000
      at __node_internal_captureLargerStackTrace (node:internal/errors:477:5)
      at __node_internal_exceptionWithHostPort (node:internal/errors:655:12)
      at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1247:16) {
    errno: -111,
    code: 'ECONNREFUSED',
    syscall: 'connect',
    address: '127.0.0.1',
    port: 3000
  },
  [Symbol(kMessage)]: 'connect ECONNREFUSED 127.0.0.1:3000'
}
22:08:25.184 ERR connection error Ds {
  [Symbol(kTarget)]: ye {
    _events: [Object: null prototype] {
      error: [Function],
      close: [Function],
      open: [Function],
      message: [Function]
    },
    _eventsCount: 4,
    _maxListeners: undefined,
    _binaryType: 'nodebuffer',
    _closeCode: 1006,
    _closeFrameReceived: false,
    _closeFrameSent: false,
    _closeMessage: <Buffer >,
    _closeTimer: null,
    _extensions: {},
    _paused: false,
    _protocol: '',
    _readyState: 2,
    _receiver: null,
    _sender: null,
    _socket: null,
    _bufferedAmount: 0,
    _isServer: false,
    _redirects: 0,
    _autoPong: true,
    _url: 'ws://localhost:3000/query',
    _req: null,
    [Symbol(kCapture)]: false
  },
  [Symbol(kType)]: 'error',
  [Symbol(kError)]: Error: connect ECONNREFUSED 127.0.0.1:3000
      at __node_internal_captureLargerStackTrace (node:internal/errors:477:5)
      at __node_internal_exceptionWithHostPort (node:internal/errors:655:12)
      at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1247:16) {
    errno: -111,
    code: 'ECONNREFUSED',
    syscall: 'connect',
    address: '127.0.0.1',
    port: 3000
  },
  [Symbol(kMessage)]: 'connect ECONNREFUSED 127.0.0.1:3000'
}
22:08:31.710 ERR connection error Ds {
  [Symbol(kTarget)]: ye {
    _events: [Object: null prototype] {
      error: [Function],
      close: [Function],
      open: [Function],
      message: [Function]
    },
    _eventsCount: 4,
    _maxListeners: undefined,
    _binaryType: 'nodebuffer',
    _closeCode: 1006,
    _closeFrameReceived: false,
    _closeFrameSent: false,
    _closeMessage: <Buffer >,
    _closeTimer: null,
    _extensions: {},
    _paused: false,
    _protocol: '',
    _readyState: 2,
    _receiver: null,
    _sender: null,
    _socket: null,
    _bufferedAmount: 0,
    _isServer: false,
    _redirects: 0,
    _autoPong: true,
    _url: 'ws://localhost:3000/query',
    _req: null,
    [Symbol(kCapture)]: false
  },
  [Symbol(kType)]: 'error',
  [Symbol(kError)]: Error: connect ECONNREFUSED 127.0.0.1:3000
      at __node_internal_captureLargerStackTrace (node:internal/errors:477:5)
      at __node_internal_exceptionWithHostPort (node:internal/errors:655:12)
      at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1247:16) {
    errno: -111,
    code: 'ECONNREFUSED',
    syscall: 'connect',
    address: '127.0.0.1',
    port: 3000
  },
  [Symbol(kMessage)]: 'connect ECONNREFUSED 127.0.0.1:3000'
}
22:08:43.464 INF server: started

Anything else?

Server Information: Static hostname: XXXXX Icon name: computer-vm Chassis: vm Machine ID: XXXXXX Boot ID: XXXXXXX Virtualization: amazon Operating System: Ubuntu 22.04.3 LTS Kernel: Linux 6.5.0-1018-aws Architecture: x86-64 Hardware Vendor: Amazon EC2 Hardware Model: t3a.medium

Code of Conduct

npaton commented 4 months ago

Thank you for the report. I have not had the chance to look into this yet but I will as soon as possible.

npaton commented 2 months ago

Sorry for the delay. I'm thinking the server is taking some time to initialize and the callbacks are attempting to connect to it too early. Does the system work once the error messages subside? It looks like it's taking 15-20s for the server to start in this case, which can happen if the tajriba file starts to be a bit large (it can grow quite quickly when storing very frequent events such as mouse movements of the players).