javax.mail.Transport.send0() not throwing the exceptions it's promising - java

when i'm sending an email to a false domain, say to test#rstjhajh.com, i'm receiving and email to the sender address, with message body:
The following message to <test#rstjhajh.com> was undeliverable.
The reason for the problem:
5.1.2 - Bad destination host 'DNS Hard Error looking up rstjhajh.com (MX): NXDomain'
and an attachment
Reporting-MTA: dns; ironport2-out.teksavvy.com
Final-Recipient: rfc822;test#rstjhajh.com
Action: failed
Status: 5.0.0 (permanent failure)
Diagnostic-Code: smtp; 5.1.2 - Bad destination host 'DNS Hard Error looking up rstjhajh.com (MX): NXDomain' (delivery attempts: 0)
Transport.send() is not throwing any exceptions.
How is that possible??? a naive Q. but burned my time & there it is.
TIA.
//============
EDIT:
rstjhajh.com is not a registered DNS server. There's no email server to accept and hand-shake on it - when i look it up on DNS, i'm getting a NamingException. to whose "door" is Transport.send() delivering it??

This happens because mail is an asynchronous protocol. Transport.send() throws an exception if the e-mail can not be sent to the mail server or if that mail server rejects it (unknown host for example).
What is happening here is that the e-mail is correctly sent to (and accepted by) the mail server, but that server can not deliver it because the e-mail address does not exist.
You can not rely on Transport.send() throwing exceptions to determine if the e-mail you sent was correctly delivered. The only way is to check the address that was used to send it for undelivered messages.

Related

How to fix tinyRadius bad packet: Invalid identifier exception?

I'm using TinyRadius library and a FreeRadius server for authentication in a Spring boot app. Authentication works fine for about 4 requests, then I start getting "Error occurred while authenticating user. Message: bad packet: invalid packet identifier (request: 5, response: 4") The request number matches the one I see in the FreeRadius server by the way.
I had the same problem and I had deployed some workaround. This kind of problem in my situation was very rare. In case of RadiusException I use close() method to close socket and I am creating new object of RadiusClient class, which has the same hostname and secret as old RadiusClient object. In other way I recreate Radius socket. Maybe it's not the best solution, but I didn't want to modify code of TinyRadius library.

Remote server not found in XMPP

i send Packet to client
<iq id="kGufc-4" to="tp#localhsot" from="admin#localhost" type="get"><query xmlns='http://localhost/protocol/disco#info'/></iq>
And received
<iq id="kGufc-4" to="admin#localhost/testchat" from="tp#localhsot" type="error"><error code="404" type="CANCEL"><remote-server-not-found xmlns="urn:ietf:params:xml:ns:xmpp-stanzas"/></error></iq>
what is problem???
You have two problems with that stanza.
1) You've typod 'localhsot' instead of 'localhost'.
2) You're putting a 'from' on the stanza. Assuming you're a client sending this, it is better to not use a 'from', and let the server stamp it itself, as if you get the 'from' wrong, the server will start rejecting stanzas. In your case it's wrong as you're using the bare JID of the client, not the full JID.
Try resolving those first, and then seeing what happens.

How to enclose the username to the message and then get it from there?

I'm sending messages using java.net. And the server part works with many clients and depending on from what client I receive the message I choose the way to process the message. As I think I need to encolose the username to the message and then get it from there making the rest of the message as it was and sending it for the proceissing. How to do this? How such issues are usually resolved?
When you then receiver data, you can identify the client based on the sender's IP-address. If you still need the clientname, then send it as part of the first message after opening the connection. You can then relate the clientname with its IP-address.

mina writefuture returns written=true despite failing

This is the code
WriteFuture writeFuture = session.write(message);
writeFuture.addListener(this);
writeFuture.awaitUninterruptibly();
sentMessage = writeFuture.isWritten();
Before sending a message, I disconnect the server from the network (pull cable) so that the message cannot possibly be sent. However, sentMessage will return true anyway. On wiresharks output you can see three TCP Retransmissions (and obviously no acks). After a few more messages (not the same message as the first) it will realize the link is down and return false.
I thought this isWritten() told you if the packet was successfully sent but apparently this is not so. How do I know if the packet has arrived? I tried mina version 2.0.7 and 2.0.4
The write success is declared when the message is pushed to the kernel.
This is how socket works you can't know when the TCP message is sent or acked

connect to a lacewing server chat

I'm trying to make a port of a chat program a friend of mine made with lacewing and multimedia fusion 2 for android device.
I've managed to create a socket connecting to the listening socket of the server successfully, but I cannot seem to be able to send data to login and enter the chat. The login for now just requires a name, but even if I send a String of data, the server doesn't seem to reply or accept that data to get me over the channel.
I know I could easily port this with other way like using the NDK of the multimedia fusion 2 exporter, but I just want to figure out how this works
PS: I'm using Java and libgdx for the development
You need to read the liblacewing relay protocol:
https://github.com/udp/lacewing/blob/0.2.x/relay/current_spec.txt
On initial connection, you have to send byte 0 to identify that you are not an HTTP client. After this, you can exchange normal protocol messages.
The first message you need to send is the connection request (which may be denied by the server with a deny message). This would be:
byte 0 (2.1.0 request)
(1.2 size)
byte 0 (2.1.0.0 connection request)
string "revision 3" (2.1.0.0 connection request -> version)
When the server responds with response 0 (2.2.0.0 Connect), you then have to set a name before you may join any channels. This is done with message 2.1.0.1 SetName, which is the same structure as above but instead of 2.1.0.0's byte 0, it is 2.1.0.1's byte 1, followed by the name as a string instead of the protocol version.
The server should then respond with 2.2.0.1 SetName, assuming it accepted your name change request. You should process this message in case the server gave you a different name than you requested. Finally, once you have a name, you can join a channel with 2.1.0.2 JoinChannel. The flags you specify here will be used if the channel doesn't exist yet (e.g. nobody is in the chat yet) - these should match the ones in the MMF2 project file. The name should also match.
After all that, you're still not done! You have to process more messages, etc. it's almost like writing the RelayClient class yourself. It's a tough task, but with the protocol specification in hand you should be able to work it all out.

Categories