HTTP4 component is ignoring my protocol, hostname and port numbber - apache-camel

I am trying to call an https service. The URL is
https4://httpbin.org/get?connectTimeout=800
but it is trying to connect to
http://localhost:8080/api/v1/raw?connectTimeout=800
restConfiguration()
.component("restlet").port(8080)
.bindingMode(RestBindingMode.off)
.apiContextPath("api-doc")
.apiProperty("api.title", "Unified Item API")
.apiProperty("api.version", "v1");
rest().path("/api/v1/raw")
.get().to("direct:agg");
from("direct:agg")
.validate(authorizationPredicate)
.to("https4://httpbin.org/get?connectTimeout=800");
This is the relevant portion of the log:
12:56:12.522 [Restlet-1916062307] DEBUG o.a.camel.processor.SendProcessor - >>>> direct://agg Exchange[ID-C02VNC5EHTD5MBP-1569603368539-0-2]
12:56:12.736 [Restlet-1916062307] DEBUG o.a.c.p.v.PredicateValidatingProcessor - Validation succeed for Exchange[ID-C02VNC5EHTD5MBP-1569603368539-0-2] with Predicate[com.homedepot.merch.unifiedItemApi.predicates.AuthorizationPredicate#198c8572]
12:56:12.737 [Restlet-1916062307] DEBUG o.a.camel.processor.SendProcessor - >>>> https4://httpbin.org/get?connectTimeout=800 Exchange[ID-C02VNC5EHTD5MBP-1569603368539-0-2]
12:56:12.747 [Restlet-1916062307] DEBUG o.s.b.f.s.DefaultListableBeanFactory - Creating instance of bean 'org.apache.camel.component.jackson.converter.JacksonTypeConverters'
12:56:12.757 [Restlet-1916062307] DEBUG o.s.b.f.s.DefaultListableBeanFactory - Finished creating instance of bean 'org.apache.camel.component.jackson.converter.JacksonTypeConverters'
12:56:12.759 [Restlet-1916062307] DEBUG o.a.c.component.http4.HttpProducer - Executing http GET method: http://localhost:8080/api/v1/raw?connectTimeout=800
12:56:12.773 [Restlet-1916062307] DEBUG o.a.h.c.protocol.RequestAddCookies - CookieSpec selected: default
12:56:12.780 [Restlet-1916062307] DEBUG o.a.h.c.protocol.RequestAuthCache - Auth cache not set in the context
12:56:12.781 [Restlet-1916062307] DEBUG o.a.h.i.c.BasicHttpClientConnectionManager - Get connection for route {}->http://localhost:8080
12:56:12.790 [Restlet-1916062307] DEBUG o.a.h.i.c.DefaultManagedHttpClientConnection - http-outgoing-0: set socket timeout to 0
12:56:12.791 [Restlet-1916062307] DEBUG o.a.h.impl.execchain.MainClientExec - Opening connection {}->http://localhost:8080
12:56:12.792 [Restlet-1916062307] DEBUG o.a.h.i.c.DefaultManagedHttpClientConnection - http-outgoing-0: Shutdown connection
12:56:12.792 [Restlet-1916062307] DEBUG o.a.h.impl.execchain.MainClientExec - Connection discarded
12:56:12.792 [Restlet-1916062307] DEBUG o.a.h.i.c.BasicHttpClientConnectionManager - Releasing connection [Not bound]
12:56:12.793 [Restlet-1916062307] INFO o.a.http.impl.execchain.RetryExec - I/O exception (org.apache.http.conn.UnsupportedSchemeException) caught when processing request to {}->http://localhost:8080: http protocol is not supported
12:56:12.794 [Restlet-1916062307] DEBUG o.a.http.impl.execchain.RetryExec - http protocol is not supported
org.apache.http.conn.UnsupportedSchemeException: http protocol is not supported
at org.apache.http.impl.conn.DefaultHttpClientConnectionOperator.connect(DefaultHttpClientConnectionOperator.java:109)
at org.apache.http.impl.conn.BasicHttpClientConnectionManager.connect(BasicHttpClientConnectionManager.java:325)
at org.apache.http.impl.execchain.MainClientExec.establishRoute(MainClientExec.java:381)
at org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:237)
at org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:185)
at org.apache.http.impl.execchain.RetryExec.execute(RetryExec.java:89)
at org.apache.http.impl.execchain.RedirectExec.execute(RedirectExec.java:111)
at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:185)
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:83)
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:56)
at org.apache.camel.component.http4.HttpProducer.executeMethod(HttpProducer.java:334)

It turns out that the REST consumer sets the header Exchange.HTTP_URI to the URL it received. The HTTP4 producer uses this header to override what is in the URL it is given. The solution was to remove the header like this:
from("direct:agg")
.validate(authorizationPredicate)
.removeHeader("Exchange.HTTP_URI")

Related

Unble to open multiple simultaneous websockets to the same endpoint in case where the consumer is busy for the first websocket

I am using Django channels with React websockets. I am unable to open multiple simulataneous websockets if the consumer of the first websocket channel is busy with some activity. I want to open multiple simultaneous websockets where consumers is doing something for each individual websocket.
The module versions are:
asgiref 3.6.0
daphne 3.0.2
django-cors-headers 3.13.0
djangorestframework 3.14.0
djangorestframework-simplejwt 5.2.2
From the snippet below, once one websocket completes the task the second websocket can be connected (in a separate tab) but while 1st websocket is busy (sleeping), the other websockets in the new browser tabs fails after handshake with the following error:
**
WebSocket HANDSHAKING /ws/socket-server/monitor-rack-kpis/ushoeuhrti/ [127.0.0.1:49228]
django.channels.server INFO WebSocket HANDSHAKING /ws/socket-server/monitor-rack-kpis/ushoeuhrti/ [127.0.0.1:49228]
daphne.http_protocol DEBUG Upgraded connection ['127.0.0.1', 49228] to WebSocket
daphne.ws_protocol DEBUG WebSocket closed for ['127.0.0.1', 49228]
WebSocket DISCONNECT /ws/socket-server/monitor-rack-kpis/ushoeuhrti/ [127.0.0.1:49228]
django.channels.server INFO WebSocket DISCONNECT /ws/socket-server/monitor-rack-kpis/ushoeuhrti/ [127.0.0.1:49228]
daphne.server WARNING Application instance <Task pending name='Task-56' coro=<StaticFilesWrapper.__call__() running at /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/channels/staticfiles.py:44> wait_for=<Future pending cb=[_chain_future.<locals>._call_check_cancel() at /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/asyncio/futures.py:387, Task.task_wakeup()]>> for connection <WebSocketProtocol client=['127.0.0.1', 49216] path=b'/ws/socket-server/monitor-rack-kpis/vhofoefwmr/'> took too long to shut down and was killed.
**
I tried using url in routing instead of re_path but that didn't help either
settings.py
`
ASGI_APPLICATION = 'backend.asgi.application'
CHANNEL_LAYERS={'default':{'BACKEND':'channels.layers.InMemoryChannelLayer'}}
`
asgi.py
application = ProtocolTypeRouter({
'http':get_asgi_application(),
'websocket':AuthMiddlewareStack(
URLRouter(logstatus.routing.websocket_urlpatterns)
)
})
routing.py
websocket_urlpatterns=[
re_path(r'^ws/socket-server/monitor-rack-kpis/(?P<username>[A-Za-z]+)/', consumers.InfluxWritePromesthusConsumer.as_asgi())
]
consumer.py
class InfluxWritePromesthusConsumer(WebsocketConsumer):
def ws_connect(message):
message.reply_channel.send({"accept": True})
def receive(self, text_data):
print(f"\nReceiving from: {self.channel_name}\n")
t = 0
while t<=100:
self.send(text_data=json.dumps({
'type':"LearnSocket",
'message': "Received Messages"
}))
t += 10
time.sleep(10)
Frontend- React.JS
const randN = generate()
console.log(randN)
const socket = new WebSocket('ws://127.0.0.1:8000/ws/socket-server/monitor-rack-kpis/'+ randN+ '/');
console.log(socket)
socket.onopen=function(e){
console.log(socket.readyState)
if (user && user.access) {
socket.send("Hi");
//Receiving response from WebSocket
socket.onmessage=function(e){
//let data1=JSON.parse(e.data);
console.log(e.data, new Date());
//setOutputResponse(data1['message']);
}
}
}

Kong/Scylladb intermittent timeout issue when writing routes "received only 0 responses 2" - K8

When trying to register routes via Kong /routes, we are seeing intermittent timeout issues.
Kong and Scylladb are setup in docker/k8
[error] 41#0: *119054033 [kong] api_helpers.lua:310 could not execute insertion query: [Write timeout] Operation timed out for kong.routes - received only 0 responses from 2 CL=SERIAL., client: 10.xxx.xxx.xxx, server: kong_admin, request: \"POST /routes HTTP/1.1\"
Only happens on /routes registration call, and write_request_timeout_in_ms is set to 2000ms.
Anyone seen this issue before?

GreenMail integration test sent email not being relayed to recipient

I'm using greenmail for mail integration test, and came out with below code. The intention is to create 2 fake email servers that act as sender and recipient.
However when I ran the code, the test failed because the recipient doesn't receive the email. I've read some sample and faq from 'greenmail' site but can't find the explainations for this behavior. I hope someone could shed some light here.
Below is the test code:
#Before
public void setUp() {
// Setup fake smtp server.
ServerSetup smtpServer = new ServerSetup(Integer.parseInt(smtpPort), smtpHost, smtpProtocol);
serverA = new GreenMail(smtpServer);
serverA.start();
// Setup fake pop3 server.
ServerSetup pop3Server = new ServerSetup(Integer.parseInt(pop3Port), pop3Host, pop3Protocol);
serverB = new GreenMail(pop3Server);
serverB.start();
}
#Test
public void testSendEmailToAvailableMailboxReturnEmail() {
String senderMail = "sender.1#testmail.com";
String senderUsername = "sender1";
String senderPassword = "password123";
String receiverMail = "receiver.1#testmail.com";
String receiverUsername = "receiver1";
String receiverPassword = "pass567";
// Set mailbox for sender and receiver
serverA.setUser(senderMail, senderUsername, senderPassword);
serverB.setUser(receiverMail, receiverUsername, receiverPassword);
// Send email from serverA
String subject = "This is a test subject.";
String msg = "This is a plain test message.";
EmailModel emailModel = new EmailModel();
emailModel.setFrom(senderMail);
emailModel.setTo(receiverMail);
emailModel.setSubject(subject);
emailModel.setBody(msg);
emailModel.setSentDate(LocalDateTime.now());
emailModel.setBodyType(EmailModel.EMAIL_TYPE_TEXT);
// Using javamailsenderimpl to send the mail.
mailServiceImpl.send(emailModel);
// Retrieve email from ServerB
Session session = Session.getDefaultInstance(new Properties(), null);
try {
Store store = session.getStore(pop3Protocol);
store.connect(pop3Host, receiverUsername, receiverPassword);
Folder inbox = store.getFolder(BatchConstant.MAIL_INBOX);
inbox.open(Folder.READ_ONLY);
Message[] messages = inbox.getMessages();
Assert.assertNotNull(messages);
Assert.assertEquals(1, messages.length);
Assert.assertEquals(subject, messages[0].getSubject());
Assert.assertEquals(msg, String.valueOf(messages[0].getContent()).contains(msg));
} catch (MessagingException | IOException e) {
Assert.fail("Should be able to retrive sent mail.");
}
}
#After
public void tearDown() {
serverA.stop();
serverB.stop();
}
It fails at this line:
Assert.assertEquals(1, messages.length);
The log:
23:42:57.998 [main] DEBUG org.springframework.beans.factory.support.DefaultListableBeanFactory - Returning cached instance of singleton bean 'org.springframework.boot.test.mock.mockito.MockitoBeans'
23:42:58.014 [main] DEBUG com.icegreen.greenmail.util.GreenMail - Started services, performing check if all up
23:42:58.014 [smtp:127.111.44.233:25] DEBUG com.icegreen.greenmail.smtp.SmtpServer - Started smtp:127.111.44.233:25
23:42:58.029 [main] DEBUG com.icegreen.greenmail.util.GreenMail - Started services, performing check if all up
23:42:58.029 [pop3:127.124.244.10:110] DEBUG com.icegreen.greenmail.pop3.Pop3Server - Started pop3:127.124.244.10:110
23:42:58.061 [main] DEBUG org.springframework.beans.factory.support.DefaultListableBeanFactory - Returning cached instance of singleton bean 'getJavaMailSender'
DEBUG: JavaMail version 1.5.6
DEBUG: successfully loaded resource: /META-INF/javamail.default.providers
DEBUG: Tables of loaded providers
DEBUG: Providers Listed By Class Name: {com.sun.mail.smtp.SMTPSSLTransport=javax.mail.Provider[TRANSPORT,smtps,com.sun.mail.smtp.SMTPSSLTransport,Oracle], com.sun.mail.smtp.SMTPTransport=javax.mail.Provider[TRANSPORT,smtp,com.sun.mail.smtp.SMTPTransport,Oracle], com.sun.mail.imap.IMAPSSLStore=javax.mail.Provider[STORE,imaps,com.sun.mail.imap.IMAPSSLStore,Oracle], com.sun.mail.pop3.POP3SSLStore=javax.mail.Provider[STORE,pop3s,com.sun.mail.pop3.POP3SSLStore,Oracle], com.sun.mail.imap.IMAPStore=javax.mail.Provider[STORE,imap,com.sun.mail.imap.IMAPStore,Oracle], com.sun.mail.pop3.POP3Store=javax.mail.Provider[STORE,pop3,com.sun.mail.pop3.POP3Store,Oracle]}
DEBUG: Providers Listed By Protocol: {imaps=javax.mail.Provider[STORE,imaps,com.sun.mail.imap.IMAPSSLStore,Oracle], imap=javax.mail.Provider[STORE,imap,com.sun.mail.imap.IMAPStore,Oracle], smtps=javax.mail.Provider[TRANSPORT,smtps,com.sun.mail.smtp.SMTPSSLTransport,Oracle], pop3=javax.mail.Provider[STORE,pop3,com.sun.mail.pop3.POP3Store,Oracle], pop3s=javax.mail.Provider[STORE,pop3s,com.sun.mail.pop3.POP3SSLStore,Oracle], smtp=javax.mail.Provider[TRANSPORT,smtp,com.sun.mail.smtp.SMTPTransport,Oracle]}
DEBUG: successfully loaded resource: /META-INF/javamail.default.address.map
DEBUG: getProvider() returning javax.mail.Provider[TRANSPORT,smtp,com.sun.mail.smtp.SMTPTransport,Oracle]
DEBUG SMTP: useEhlo true, useAuth false
DEBUG SMTP: trying to connect to host "127.111.44.233", port 25, isSSL false
23:42:58.170 [smtp:127.111.44.233:25] DEBUG com.icegreen.greenmail.smtp.SmtpServer - Handling new client connection smtp:127.111.44.233:25<-/127.0.0.1:55846
220 /127.111.44.233 GreenMail SMTP Service v1.5.7 ready
DEBUG SMTP: connected to host "127.111.44.233", port: 25
EHLO MXXXXXXXXX
250 /127.111.44.233
DEBUG SMTP: use8bit false
MAIL FROM:<sender.1#testmail.com>
250 OK
RCPT TO:<receiver.1#testmail.com>
250 OK
DEBUG SMTP: Verified Addresses
DEBUG SMTP: receiver.1#testmail.com
DATA
354 Start mail input; end with <CRLF>.<CRLF>
Date: Tue, 12 Jun 2018 23:42:58 +0800 (SGT)
From: sender.1#testmail.com
To: receiver.1#testmail.com
Message-ID: <2074658615.2.1528818178201#MXXXXXXXXX>
Subject: This is a test subject.
MIME-Version: 1.0
Content-Type: multipart/mixed;
boundary="----=_Part_0_52514534.1528818178108"
------=_Part_0_52514534.1528818178108
Content-Type: multipart/related;
boundary="----=_Part_1_1046665075.1528818178123"
------=_Part_1_1046665075.1528818178123
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit
This is a plain test message.
------=_Part_1_1046665075.1528818178123--
------=_Part_0_52514534.1528818178108--
.
23:42:58.217 [smtp:127.111.44.233:25<-/127.0.0.1:55846] INFO com.icegreen.greenmail.smtp.SmtpManager - Created user login receiver.1#testmail.com for address receiver.1#testmail.com with password receiver.1#testmail.com because it didn't exist before.
250 OK
DEBUG SMTP: message successfully delivered to mail server
QUIT
221 /127.111.44.233 Service closing transmission channel
23:42:58.264 [pop3:127.124.244.10:110] DEBUG com.icegreen.greenmail.pop3.Pop3Server - Handling new client connection pop3:127.124.244.10:110<-/127.0.0.1:55847
23:42:58.264 [pop3:127.124.244.10:110<-/127.0.0.1:55847] DEBUG com.icegreen.greenmail.pop3.Pop3Connection - S: +OK POP3 GreenMail Server v1.5.7 ready
23:42:58.279 [pop3:127.124.244.10:110<-/127.0.0.1:55847] DEBUG com.icegreen.greenmail.pop3.Pop3Connection - C: CAPA
23:42:58.279 [pop3:127.124.244.10:110<-/127.0.0.1:55847] DEBUG com.icegreen.greenmail.pop3.Pop3Connection - S: +OK
23:42:58.279 [pop3:127.124.244.10:110<-/127.0.0.1:55847] DEBUG com.icegreen.greenmail.pop3.Pop3Connection - S: UIDL
23:42:58.279 [pop3:127.124.244.10:110<-/127.0.0.1:55847] DEBUG com.icegreen.greenmail.pop3.Pop3Connection - S: .
23:42:58.279 [pop3:127.124.244.10:110<-/127.0.0.1:55847] DEBUG com.icegreen.greenmail.pop3.Pop3Connection - C: USER receiver1
23:42:58.279 [pop3:127.124.244.10:110<-/127.0.0.1:55847] DEBUG com.icegreen.greenmail.pop3.Pop3Connection - S: +OK
23:42:58.279 [pop3:127.124.244.10:110<-/127.0.0.1:55847] DEBUG com.icegreen.greenmail.pop3.Pop3Connection - C: PASS pass567
23:42:58.279 [pop3:127.124.244.10:110<-/127.0.0.1:55847] DEBUG com.icegreen.greenmail.pop3.Pop3Connection - S: +OK
23:42:58.279 [pop3:127.124.244.10:110<-/127.0.0.1:55847] DEBUG com.icegreen.greenmail.pop3.Pop3Connection - C: STAT
23:42:58.279 [pop3:127.124.244.10:110<-/127.0.0.1:55847] DEBUG com.icegreen.greenmail.pop3.Pop3Connection - S: +OK 0 0
23:42:58.279 [pop3:127.124.244.10:110<-/127.0.0.1:55847] DEBUG com.icegreen.greenmail.pop3.Pop3Connection - C: NOOP
23:42:58.279 [pop3:127.124.244.10:110<-/127.0.0.1:55847] DEBUG com.icegreen.greenmail.pop3.Pop3Connection - S: +OK noop rimes with poop
23:42:58.279 [main] DEBUG com.icegreen.greenmail.util.GreenMail - Stopping GreenMail ...
23:42:58.279 [main] DEBUG com.icegreen.greenmail.util.GreenMail - Stopping service smtp:127.111.44.233:25
23:42:58.295 [main] DEBUG com.icegreen.greenmail.smtp.SmtpServer - Stopping smtp:127.111.44.233:25
23:42:58.295 [main] DEBUG com.icegreen.greenmail.smtp.SmtpServer - Stopped smtp:127.111.44.233:25
23:42:58.295 [main] DEBUG com.icegreen.greenmail.util.GreenMail - Stopping GreenMail ...
23:42:58.295 [main] DEBUG com.icegreen.greenmail.util.GreenMail - Stopping service pop3:127.124.244.10:110
23:42:58.295 [main] DEBUG com.icegreen.greenmail.pop3.Pop3Server - Stopping pop3:127.124.244.10:110
23:42:58.295 [main] DEBUG com.icegreen.greenmail.pop3.Pop3Server - Stopped pop3:127.124.244.10:110
23:42:58.295 [main] DEBUG org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate - Retrieved ApplicationContext from cache with key [[MergedContextConfiguration#4e7dc304 testClass = MailServiceImplTest, locations = '{}', classes = '{class com.xxx.xoxoxo.mail.service.impl.MailServiceImpl, class com.xxx.xoxoxo.config.MailServiceConfig, class com.xxx.xoxoxo.batch.encryption.AesEncryptor, class com.xxx.xoxoxo.config.ApplicationProperties}', contextInitializerClasses = '[]', activeProfiles = '{}', propertySourceLocations = '{}', propertySourceProperties = '{enote.mail.host=127.111.44.233, enote.mail.port=25, enote.mail.protocol=smtp, enote.mail.encoding=UTF-8, enote.mail.auth=false, enote.mail.username=, enote.mail.password=}', contextCustomizers = set[org.springframework.boot.test.context.filter.ExcludeFilterContextCustomizer#59f99ea, org.springframework.boot.test.json.DuplicateJsonObjectContextCustomizerFactory$DuplicateJsonObjectContextCustomizer#47c62251, org.springframework.boot.test.mock.mockito.MockitoContextCustomizer#0, org.springframework.boot.test.autoconfigure.properties.PropertyMappingContextCustomizer#0, org.springframework.boot.test.autoconfigure.web.servlet.WebDriverContextCustomizerFactory$Customizer#589838eb], contextLoader = 'org.springframework.test.context.support.DelegatingSmartContextLoader', parent = [null]]]
23:42:58.295 [main] DEBUG org.springframework.test.context.cache - Spring test ApplicationContext cache statistics: [DefaultContextCache#645aa696 size = 1, maxSize = 32, parentContextCount = 0, hitCount = 2, missCount = 1]
GreenMail is a sandbox server. It will never route mail to another server.
What you want to do is create a single instance of GreenMail,
configured for both SMTP and POP3:
ServerSetup smtpServerSetup = ...
ServerSetup pop3ServerSetup = ...
GreenMail greenMail = new GreenMail(new ServerSetup[]{smtpServerSetup, pop3ServerSetup});
greenMail.start(); // Starts both smtp and pop3

Camel HL7 - ClosedChannelException while sending ACK back to the client

I'm building a HL7 listener using netty4 and processing HL7 messages. Once succesfully processed an ACK is sent back.
from("hl7NettyListener")
.routeId("route_hl7listener")
.startupOrder(997)
.unmarshal()
.hl7(false)
.to("direct:a");
from("direct:a")
.doTry()
.to("bean:processHL7?method=process")
.doCatch(HL7Exception.class)
.to("direct:ErrorACK")
//.transform(ack())
.stop()
.end()
.transform(ack())
.wireTap("direct:b");
This is working fine in my local eclipse. I fire a HL7 message and I get a ACk back.
But i package this application into a jar and put it on my server and then try doing a
cat example.hl7 | netcat localhost 4444 (to fire a HL7 message to port 4444 on linux env)
I dont get an ACK back. I get a closedconnection exception.
DEBUG NettyConsumer - Channel: [id: 0xdf13b06b, L:0.0.0.0/0.0.0.0:4444] writing body: MSH|^~\&|Karisma||Kestral|Kestral|20180309144109.827+1300||ACK^R01|701||2.3.1
2018-03-09 14:41:09,838 [ad #3 - WireTap] DEBUG WireTapProcessor - >>>> (wiretap) direct:b Exchange[]
2018-03-09 14:41:09,839 [ServerTCPWorker] DEBUG NettyConsumer - Caused by: [org.apache.camel.CamelExchangeException - Cannot write response to null. Exchange[ID-annan06-56620-1520559639101-0-2]. Caused by: [java.nio.channels.ClosedChannelException - null]]
org.apache.camel.CamelExchangeException: Cannot write response to null. Exchange[ID-annan06-56620-1520559639101-0-2]. Caused by: [java.nio.channels.ClosedChannelException - null]
at org.apache.camel.component.netty4.handlers.ServerResponseFutureListener.operationComplete(ServerResponseFutureListener.java:54)
at org.apache.camel.component.netty4.handlers.ServerResponseFutureListener.operationComplete(ServerResponseFutureListener.java:36)
at io.netty.util.concurrent.DefaultPromise.notifyListener0(DefaultPromise.java:514)
at io.netty.util.concurrent.DefaultPromise.notifyListenersNow(DefaultPromise.java:488)
at io.netty.util.concurrent.DefaultPromise.access$000(DefaultPromise.java:34)
at io.netty.util.concurrent.DefaultPromise$1.run(DefaultPromise.java:438)
at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:163)
at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:418)
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:440)
at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:873)
at java.lang.Thread.run(Thread.java:748)
Caused by: java.nio.channels.ClosedChannelException
at io.netty.channel.AbstractChannel$AbstractUnsafe.write(...)(Unknown Source)
That worked. It was failing because netcat was immediately closing the connection. Had put a ”netcat -i 5 localhost” for netcat to wait for 5 secs and successfully received the ACK back.

JGroups, TCP_NIO multiple messages sent to nowhere

Messages sent to ports I never specified in my configuration file.
this is my config:
[10-Jan-2011 11:02:22.917 GMT] ERROR org.jgroups.protocols.TCP_NIO - failed sending message to 192.168.50.41:8851 (116 bytes): java.lang.Exception: connection to 192.168.50.41:8851 could not be established
[10-Jan-2011 11:02:22.917 GMT] WARN org.jgroups.blocks.ConnectionTableNIO - Connection is not running, discarding message
Because you have a port_range of 2, so every discovery message is sent to all of the initial_hosts defined in TCPPING, plus port_range, e.g.
TCPPING.initial_hosts=A[1000],B[1000]
port_range=2
will send discovery requests to A:1000-1002, B:1000-1002.
TCPPING is used at startup for initial discovery and by MERGE2 (not in your stack)...

Resources