Communication JavaScript application (client) and a Julia application (server)

I need to create a communication via socket between a javascript application (client) and a julia application (server).

I searched the forum and didn’t find something that works, can someone help me with an example that works?

# server written in Julia
using Sockets
@async begin
    server = listen(ip"", 2812)
    while true
        sock = accept(server)
        @async while isopen(sock)
            write(sock, "echo: " * readline(sock) * "\n")
# client written in JavaScript - Not work
const WebSocket = require('ws');
const ws = new WebSocket('ws://')

ws.on("connection", () => {

ws.addEventListener('message', message => {

ws.onopen = function(e) {

ws.onmessage = function(data) { 


Isn’t it all here? JuliaWeb · GitHub

Julia can work as a web server for you, for Genie.jl (or use external web server).

Possibly this one helps GitHub - wookay/Bukdu.jl: Bukdu 🌌 is a web development framework for Julia and JuliaWebAPI.jl (e.g. ZMQTransport or JSONMsgFormat?), WebSockets.jl, WebIO.jl (with example) and GitHub - JuliaGizmos/JSExpr.jl: Translate Julia to JavaScript

My question is that I need to develop the real-time system (back-end and front-end) in which the back-end will be developed in julia and the front-end in javascript, communication via websocket, I put the example code in the first post.

You should use a WebSocket library unless you want to implement the WebSocket protocol RFC 6455 - The WebSocket Protocol over a TCP socket yourself. Try GitHub - JuliaWeb/WebSockets.jl: A WebSockets library for Julia.

1 Like