-
30. Re: How to begin...2 instances of JB MS, 2 NICS, 1 JB AS
gohip Jun 2, 2006 9:16 PM (in response to gohip)ehhh, yuck, it looks like I have to compile, distribute, and the install again...
is there any shortcut? i.e. just copy this and that folders, it looks like the AOP is screwing me up again... -
31. Re: How to begin...2 instances of JB MS, 2 NICS, 1 JB AS
acoliver Jun 2, 2006 11:43 PM (in response to gohip)export JBOSS_HOME=.....
ant clean compile test-deploy -
32. Re: How to begin...2 instances of JB MS, 2 NICS, 1 JB AS
gohip Jun 3, 2006 8:59 PM (in response to gohip)k, i got it running, but now, both on my test machine at home, as well on our test mail server remote, i get this error...
20:16:00,203 INFO [SMTPSender] **********JAYS DEBUG:SMTPSender:BEGIN creating protocol with host=mx2.mail.yahoo.com.
20:16:00,203 INFO [SMTPSender] **********JAYS DEBUG:SMTPSender:Begin creating ENHANCED protocol with host=mx2.mail.yahoo.com.
20:16:00,203 INFO [SMTPSender] **********JAYS DEBUG:SMTPSender:FINISH creatingENHANCED protocol
20:16:00,203 INFO [SMTPSender] **********JAYS DEBUG:SMTPSender:sendForDomain:opening port
20:16:00,203 INFO [STDOUT] **********Jays Debug:org.columba.ristretto.smtp.SMTPProtocol:openPort:Using Jays Enhaned Socket
20:16:00,203 INFO [STDOUT] **********Jays Debug:SocketSettings:localHost=mail.myDomain.com/216.122.135.199
20:16:00,203 INFO [STDOUT] **********Jays Debug:SocketSettings:=localPort 10952
20:16:00,203 INFO [STDOUT] **********Jays Debug:SocketSettings:=remoteHost mx2.mail.yahoo.com.
20:16:00,218 INFO [STDOUT] **********Jays Debug:SocketSettings:=remotePort 25
20:16:00,218 ERROR [STDERR] java.net.BindException: Address already in use: JVM_Bind
20:16:00,218 ERROR [STDERR] at java.net.PlainSocketImpl.socketBind(Native Method)
20:16:00,218 ERROR [STDERR] at java.net.PlainSocketImpl.bind(PlainSocketImpl.java:359)
20:16:00,218 ERROR [STDERR] at java.net.Socket.bind(Socket.java:553)
20:16:00,218 ERROR [STDERR] at java.net.Socket.(Socket.java:363)
20:16:00,218 ERROR [STDERR] at java.net.Socket.(Socket.java:238)
20:16:00,218 ERROR [STDERR] at org.columba.ristretto.smtp.SMTPProtocol.openPort(SMTPProtocol.java:186)
20:16:00,218 ERROR [STDERR] at org.jboss.mail.smtp.sender.SMTPSender.sendForDomain(SMTPSender.java:549)
when I ran netstat, and happened to catch the connections
i could see this...
TCP 216.122.135.199:25 0.0.0.0:0 LISTENING 1712
TCP 216.122.135.199:25 130.13.115.197:4236 TIME_WAIT 0
TCP 216.122.135.199:10952 67.28.113.73:25 ESTABLISHED 1712
so what we have, is my home computer (130.13.115.197:4236) connected to the mail server (216.122.135.199:25) then the mail server,
is connected on port 10952 to yahoo mail server (67.28.113.73:25)
Andrew, or Mike, I dont understand why it says it cant bind to the address, as from the above output, it looks like it is binding to the address
any ideas, I did exactly what you said Andrew, adding as I said this too
ristrettos smtpprotocolsocket = new Socket(remoteHost, remotePort, localHost, localPort);
then adding this too smtpsender
this gets called first//protocol = new SMTPProtocol(host); //and catch below //log.info("**********JAYS DEBUG:SMTPSender:FINISH creating protocol with host=" + host); log.info("**********JAYS DEBUG:SMTPSender:Begin creating ENHANCED protocol with host=" + host); protocol = new SMTPProtocol(host, 25, InetAddress.getByName("mail.myDomain.com"), 10952); //and catch below log.info("**********JAYS DEBUG:SMTPSender:FINISH creating ENHANCED protocol");
then the following code, which I didnt modifylog.info("**********JAYS DEBUG:SMTPSender:sendForDomain:opening port"); log.info("**********protocol.openPort(returns server name)=" + protocol.openPort()); log.info("**********JAYS DEBUG:SMTPSender:sendForDomain:opened port");
so based on the debug out, it looks like it creates an instance of the protocol fine, but when it goes to open the port, it is already open...
i wonder, if you create a socket, using the constructor i created, does it already open the port for you, and thats why it is erroring when it calls openPort()
so please, please when you guys get a moment, let me know what you think...I am so close, it's finally doing what it should, i.e creating the connection (outgoing) on the same ip address it's supposed to, I dont understand now why I get this error, especially as seeing how it is connected.
below, are the smtpprotocol code, just to refresh your memories, I'd like to do a patch also, so need to get with Mike concerning "how to"/** * Constructs the SMTPProtocol, using remote host and port, as well as * local host and port * * @param remoteHost * the remote sever name to connect to * @param remotePort * the remote port to connect to * @param localHost * the local sever name to connect to * @param localPort * the local port to connect to */ public SMTPProtocol(String rHost, int rPort, InetAddress lHost, int lPort) { this.remoteHost = rHost; this.remotePort = rPort; this.localHost = lHost; this.localPort = lPort; } /** * Constructs the SMTPProtocol. * * @param remoteHost * the remote sever name to connect to * @param remotePort * the remote port to connect to */ public SMTPProtocol(String host, int port) { this.remoteHost = host; this.remotePort = port; } /** * Constructs the SMTPProtocol. Uses the default port 25 to connect to the * server. * * @param remoteHost * the remote sever name to connect to */ public SMTPProtocol(String host) { this(host, DEFAULTPORT); } /** * Opens the connection to the SMTP server. * * @return the domain name of the server * @throws IOException * @throws SMTPException */ public String openPort() throws IOException, SMTPException { try { //jay if(localHost!=null && localPort>=-1) { //remoteHost is str, localHost is InetAddress System.out.println("**********Jays Debug:org.columba.ristretto.smtp.SMTPProtocol:openPort:Using Jays Enhaned Socket"); System.out.println("**********Jays Debug:SocketSettings:localHost=" + localHost); System.out.println("**********Jays Debug:SocketSettings:=localPort" + localPort); System.out.println("**********Jays Debug:SocketSettings:=remoteHost" + remoteHost); System.out.println("**********Jays Debug:SocketSettings:=remotePort" + remotePort); socket = new Socket(remoteHost, remotePort, localHost, localPort); System.out.println("**********Jays Debug:Socket Created"); } else { System.out.println("**********Jays Debug:org.columba.ristretto.smtp.SMTPProtocol:openPort:NOT Using Jays Enhaned Socket"); System.out.println("**********Jays Debug:SocketSettings:=remoteHost" + remoteHost); System.out.println("**********Jays Debug:SocketSettings:=remotePort" + remotePort); socket = new Socket(remoteHost, remotePort); System.out.println("**********Jays Debug:Generic Socket Created"); } //jay socket.setSoTimeout(RistrettoConfig.getInstance().getTimeout()); createStreams(); SMTPResponse response = readSingleLineResponse(); if (response.isERR()) throw new SMTPException(response.getMessage()); String domain = response.getDomain(); // don't care what the server has to say here. if (response.isHasSuccessor()) { response = readSingleLineResponse(); while (response.isHasSuccessor() && response.isOK()) { response = readSingleLineResponse(); } } state = PLAIN; return domain; } catch (SocketException e) { e.printStackTrace(); // Catch the exception if it was caused by // dropping the connection if (state != NOT_CONNECTED) throw e; else return ""; } }
Note: we were doing smtpprotocol(host) constructor, which used def port of 25
so really, i am not doing anything different it seems -
33. Re: How to begin...2 instances of JB MS, 2 NICS, 1 JB AS
gohip Jun 3, 2006 9:07 PM (in response to gohip)damn, i looked, and it does bind if you call open socket that way, it took me twenty minutes to type the above, that sucks
so i guess, in the code, I will drop the openPort method, and see what happens
see check me...
we were calling...
Creates a stream socket and connects it to the specified port number on the named host.
now calling...
public Socket(String host,
int port,
InetAddress localAddr,
int localPort)
throws IOExceptionCreates a socket and connects it to the specified remote host on the specified remote port. The Socket will also bind() to the local address and port supplied.
thanks for your patience guys, hopefully this will work, let yeah guys know...
and mike, would like to still get with you on a patch... -
34. Re: How to begin...2 instances of JB MS, 2 NICS, 1 JB AS
gohip Jun 3, 2006 9:41 PM (in response to gohip)damn, no, thats not what it was, open port, actually creates the socket
smtpprotocol constructor just sets the attributes...
so why would it still error if all i changed relates to this...
we were doing
socket(host, port) which
"Creates a stream socket and connects it to the specified port number on the named host"
now I am doing
socket(host, port, localhost, localport) which
"Creates a socket and connects it to the specified remote host on the specified remote port. The Socket will also bind() to the local address and port supplied"
so what in the openport above method, needs to be changed...
my head hurts...I guess it is erroring on creating the new socket...
but as I asid, in netstat, i could see that the port got opened -
35. Re: How to begin...2 instances of JB MS, 2 NICS, 1 JB AS
gohip Jun 4, 2006 4:42 AM (in response to gohip)oh my god, we have success!!
thanks guys for the help! not being sarcastic, you help, even if you dont reply promptly, buy letting me rant in the forums!
To all:
If you have windows 2003 advanced server (poss. older), running jboss mail server(any version) and bind the instance (regardless of talk of multiple instances) to an ip address, that is an alias ip for an ethernet card (i.e. you have 1 NIC, with multiple IP's assigned to it)
mail servers, that at a minimum do DNS lookups on the domain, will reject the email as spam/bulk email
this is because the mail servers ip address, when connecting to the external mail server, may not be the same IP address that the instance is actually bound to, thus your telling the mail server, ehlo <192.168.69.2> (bound to this instance) but the mail server may have actually connected on 192.168.69.1 ip address, thus the remote mail server, says piss off, this looks like spam....
as Andrew pointed out, it is an issue with the JBoss SMTPSender stemming from use of Ristretto packages SMTPProtocol, in that Ristretto, was calling new socket(host, port)
instead of
new socket(remoteHost, remotePort, localHost, localPort)
thus, it seems the core java, just grabs whichever ip address ?is first? and assigns it as the localhost inetaddress to the connection, blah, that doesnt work...
BTW: I searched the windows registry, and found one key, in which the alias's were listed, and the ip address, that java kept using, i.e. the wrong one, was listed first! I thought of tweaking this, and putting the ip i wanted java to use first, but then it's a remote test machine, and I didnt want to jack up the reg or not be able to connect to it.
But if I had done that, i wouldn't have found these little quirks/possible bugs in JBoss Mail servers SMTPSender...
Check this:
the current way the SMTPSender's sendForDomain method works is strange...
1. ?Bug?: the sendForDomain method has a for loop, in which each iteration, it attempts to contact one of the mail servers returned in the mx lookup, if it contacts it, for some odd reason, it quits, and moves on to the next
after each mail host, for say yahoo which has 4 has been contacted, the current code, connects only to the last one! Where i noticed the bug, was that it is 1:00 in the morning, and yahoos fourth/last server was down, when this occurred, the socket connection times out. this causes an exception, and the mail is marked for retry
theres several retries, during each, the fourth, and last mail server was down, this caused the email to go to the failed delivery queue, i think, where it was never attempted to send again.
thus the email never made it....to test the theory, I noticed that performMXLookup, was sorting the array of remote mail server MX records, i commented it out
i then restarted the mail server locally, and lo and behold, the email was sent, this was due to the fact that since the array wasnt sorted, the remote email server, that kept causing the previous problems, was only second in the array, the fourth in the array, was up
Isnt it wastefull, and unneccessary, to connect to each one, before sending the email, i.e. with four mail servers for yahoo, four connections are made, one to each mail server, just apparentlly to see if it is alive, then regardless if the last one is alive or not,and attempt is made, the socket could time out, or be refused, and the mail is never sent
would it possibly be better to connect to one, try to send mail, if it fails, connect to next in array of mx names, i.e. basically break out of for loop, after connecting to first server?
or, if the for loop, and connections are neccessary, we could, as each connection is made, store say alive, or not alive, in an array also, after the for loop, we start with first mx mail server in array, if it is "alive", if not alive, we move on to next
End ?BUG?
Also:
Enhancements(I saw while hacking at these classes):
1. we should parse the "preference" field from the MX record, if it exists, or is different, right now, it does not look like we go with the mail server domains "prefferred" mail server, especially with the array sort were doing, we jack the list all up. Yahoo, as lists a prefferred mail server, hotmail, there all considered preferred.
Effect: Could speed up and increase reliability of email getting to external mail server
2. should parse all ip's listed for a external mail server, i.e. do a nslookup mx, on yahoo, and yes, you get four mail server names, but each mail server name, has like 5 ip addresses assigned to it
we, only grab it looks like the first IP listed, thus if it fails, we consider the mail server to have failed, but there might be 3 other ip's for that mail server
this could be a bug, in that, if only one mail server, is listed in the mx record, but it has say two ip addresses assigned to it in the mx record, we only use the first, if it goes down, a user would never be able to send mail there, where as if we iterated the ip's listed, we might try another connection.
Effect: would increase reliabilty, but also, could degrade performance, but only if we connect to each one, before trying to send, as mentioned in ?bug?, i.e. hotmail, has like 30 or so ip addresses assigned to 10 mail servers records
I dont know if these are worthwhile, they seem like they are, especially the ?bug?
Andrew, can you explain the patch process, for me, so that I might possibly contribute?
Mike, could you explain, the Ristretto patch process, so that I might contribute, I see, you have the one ristretto patch, in the patch folder, what the hell is that file, i opened it, but got scared, and closed it real quick, if I have a patch say for the Ristretto SMTPProtocol, do we provide a new jar for it? or do we do like you did, with those "patch" files in jboss-mail/patch
As stated, am a little lost, but would love to help contribute...
YEEEEEEAAAAAHHHHHHHHHHH got it working! -
36. Re: How to begin...2 instances of JB MS, 2 NICS, 1 JB AS
mikezzz Jun 4, 2006 7:55 AM (in response to gohip)I have created a small wiki page with the procedure I generally follow when fixing third party libraries (e.g. ristretto, pgsql-jdbc).
http://wiki.jboss.org/wiki/Wiki.jsp?page=PatchingThirdPartyLibraries
Andy, could you also look over this an make sure it is sane.
Mike. -
37. Re: How to begin...2 instances of JB MS, 2 NICS, 1 JB AS
gohip Jun 4, 2006 3:00 PM (in response to gohip)Thanks Mike! I check it out!
Andy, yes please, sensibility check....
I gonna clear out all my debug, start from a new copy of both the Ristretto SMTPProtocol and JBoss SMTPSender
Modify exactly what needs to be modified, note the changes, and I'll post them, nice like, for comment... -
38. Re: How to begin...2 instances of JB MS, 2 NICS, 1 JB AS
acoliver Jun 5, 2006 9:11 AM (in response to gohip)The SMTPSender seems like a logic bug. If it connects it should use that one. If it fails it should go to the next one. Mike's patch page is right (should be a "patch" command appliable patch to their sourcebase).
-Andy