Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

166
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!