local copas = require "copas" local socket = require "socket" local cjson = require "cjson" local WebSocketClient = require('websocket') local client = WebSocketClient.new({ uri = "http://localhost:3000" }) function myFunction() local testJSON = { id = 123, price = 0, name = 'Alex', volume = 0 } -- print(type(testJSON) == 'table') client:send({ command = 'orders', body = testJSON }) end -- Sleep for 2 seconds (2000 ms) socket.sleep(5) myFunction() copas.loop()