Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8583607
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T21:34:40+00:00 2026-06-11T21:34:40+00:00

I’m implementing Jetty’s WebSocket.OnTextMessage. When I receive message in onMessage(String), I can reply using

  • 0

I’m implementing Jetty’s WebSocket.OnTextMessage. When I receive message in onMessage(String), I can reply using Connection object that I acquire from onOpen(Connection) previously and the client receives it properly.

However when I want to push message from server (i.e. no initial message from client) using connection.sendMessage(String), the client does not receive it. It seems like the message is being buffered, but I can’t find any method to flush it.

Does anyone know how to solve this issue? Perhaps I’m doing is incorrectly.
This is what I did

public void onOpen(final Connection connection) {
    this.connection = connection;
}

Then on another event

public void onReceive(BytesXMLMessage bytesXMLMessage) {
    byte[] data = ((BytesMessageImpl) bytesXMLMessage).getData();
    String msgToClient = new String(data);
    this.connection.sendMessage(msgToClient);
    System.out.println("onReceive:" + msgToClient);
}

But the message never received by the client

Update: Found the pattern, the message will never be sent to client whenever it contains HTTP methods keyword such as GET, POST, PUT, HEAD, etc irrespective of whether it is uppercase or lowercase.

Is there anyway to mitigate this issue?

Update: This is the very simplified implementation of WebSocketServlet that can simulate the issue

package com.test.websocket;

import org.eclipse.jetty.websocket.WebSocket;

import javax.servlet.http.HttpServletRequest;
import java.io.IOException;

public class WebSocketServlet extends org.eclipse.jetty.websocket.WebSocketServlet {
    @Override
    public WebSocket doWebSocketConnect(HttpServletRequest request, String protocol) {
        return new WebSocket.OnTextMessage() {
            private Connection connection;
            @Override
            public void onMessage(String data) {
                try {
                    connection.sendMessage("Echo: " + data);
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }

            @Override
            public void onOpen(Connection connection) {
                this.connection = connection;
            }

            @Override
            public void onClose(int closeCode, String message) {
                connection.close();
            }
        };
    }
}

And this is the web.xml

<!DOCTYPE web-app PUBLIC
 "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
 "http://java.sun.com/dtd/web-app_2_3.dtd" >

<web-app>
    <servlet>
        <servlet-name>EchoWebSocket</servlet-name>
        <servlet-class>com.test.websocket.WebSocketServlet</servlet-class>
    </servlet>
    <servlet-mapping>
        <servlet-name>EchoWebSocket</servlet-name>
        <url-pattern>/*</url-pattern>
    </servlet-mapping>
</web-app>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T21:34:41+00:00Added an answer on June 11, 2026 at 9:34 pm

    Found the root cause why it can’t send HTTP methods keyword. It was caused by Antivirus Kaspersky that is running on the development machine intercepting at the network layer for all HTTP methods keyword and it has to be working within the appropriate standard HTTP protocol. Perhaps it doesn’t support websocket protocol just yet.

    Thanks to @jesse mcconnell that was helping to create the unit test.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
Does anyone know how can I replace this 2 symbol below from the string
i got an object with contents of html markup in it, for example: string
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
I would like to count the length of a string with PHP. The string
For some reason, after submitting a string like this Jack’s Spindle from a text

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.