Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

164
Vistas
Javascript websocket not connecting

I'm trying to make a simple chat application

I have a server made with Spring running with a websocket

I've also made an android app that successfully connects to the websocket and receives and sends messages

To make testing easier I decided to make a web client for the server in html/js, but the websocket connection fails

I'm using the exact same address as I am in the android app

Heres my JS code:

$( document ). ready(function(){

    var ws = new WebSocket("ws://192.168.1.3:8080/chatwebsocket")

    ws.onmessage = function (event) {
        var msg = event.data
        $("#chat_container").append(`<p>$(msg.sender): $(msg.content))</p>`)
    }

    ws.onerror =  function (event) {
        console.log('WebSocket error: ', event);
    }

    ws.onclose = function (event) {
        console.log('WebSocket closed: ', event);
    }


    $("#message_form").onsubmit = function(data) {
        var msgContent = data.messageContent
        var msg = {"sender":"webclient", "content": msgContent}
        ws.send(JSON.stringify(msg))
    }
})

I've tested it with Chrome and Firefox and both fail Chrome just gives the message: WebSocket connection to 'ws://192.168.1.3:8080/chatwebsocket' failed:

Theres no useful info in either the error or close events

No connection is made on the server side

The web client successfully connects to wss://ws.postman-echo.com/raw for an example

Can someone please point me in the right direction with troubleshooting this because I feel like I have no info to work with

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda