WebSocket delayed compared to HTTP REST

If I log the messages for the WebSocket and the responses I get to HTTP requests, I seem to get a some HTTP responses with transactionTime that are ~350ms higher than the updates I am getting.

E.g.:

  • Send new order via HTTP request
  • WebSocket message for exmplbtc@aggTrade with transactionTime == 1000
  • WebSocket message for exmplbtc@aggTrade with transactionTime == 1010
  • HTTP response with transactionTime = 1400
  • WebSocket message for exmplbtc@aggTrade with transactionTime == 1020
  • WebSocket message for exmplbtc@aggTrade with transactionTime == 1035
  • WebSocket message for listenkey, executionReport with transactionTime == 1400

Am I doing something wrong?

Notes:

  • spot trading
  • I am only considering timestamps given by binance server; the local clock is not relevant here.

Example log, with reception of HTTP response with transactTime:…2288 between events “E”:…1944 and “E”:…1947, so a delay of ~340 ms

More details pls:

  1. Spot or Futures?
  2. Some samples of raw data you used to compare

Spot. I updated my answer with this link: https://gist.github.com/marcandre/1b3d41bb56ae387e03a1657ce425a17b . Thanks for looking at it!