| Author | 
		  Message
		 | 
		
		  | Kelvin | 
		  
		    
			  
				 Posted: Fri Aug 25, 2006 9:09 pm    Post subject: MQJE011: Socket connection attempt refused | 
				     | 
			   
			 
		   | 
		
		
		   Novice
 
 Joined: 25 Aug 2006 Posts: 10 Location: Hong Kong 
  | 
		  
		    
			  
				Dear all,
 
 
I try to copy the MSender.java from web to run in my machine but failed.  
 
Below is my code
 
 
But when i comment MQEnvironment.hostname = "10.130.48.59", this program can run.
 
 
I must to connect MQ server with other machine.  How do i fix it?  Please advise?
 
 
Thanks
 
 
Kelvin Ho
 
 
kelvin.ho@cigna.com or kelvinho2000@yahoo.com
 
 
 
 
 
import com.ibm.mq.*;
 
import java.io.*;
 
 
public class MSender {
 
 
	private static MQQueueManager qMgr;
 
 
	public MSender() {
 
		super();
 
	}
 
 
	public static void main(String args[]) {
 
		try {
 
			if (args.length < 1) {
 
				System.out.println("Missing queue name: "
 
				        + "MSender <queue name> <qmgr name (optional)>");
 
			} else {
 
				System.out.println("MSender started...");
 
 
				// create a new instance of the sample program
 
				MSender mSender = new MSender();
 
 
			            MQEnvironment.hostname = "10.130.48.59";
 
	MQEnvironment.port = 1414;
 
	MQEnvironment.CCSID = 1208;
 
				if (args.length > 1) {
 
					qMgr = new MQQueueManager(args[1]);
 
				} else {
 
					System.out.println
 
 					qMgr = new MQQueueManager("");
 
 
 
 
				}
 
 
				int openOptions = MQC.MQOO_OUTPUT;
 
				System.out.println("MSender started 4...");
 
 
				MQQueue q =
 
					qMgr.accessQueue(args[0], openOptions, null, null, null);
 
 
 
				// call method to send messages
 
				mSender.mPut(qMgr, q);
 
 
				// clean up connection
 
				q.close();
 
				qMgr.disconnect();
 
				System.out.println("MSender ended...");
 
			}
 
 
		} catch (MQException ex) {
 
			System.out.println(
 
				"WMQ exception occurred : Completion code "
 
					+ ex.completionCode
 
					+ " Reason code "
 
					+ ex.reasonCode );
 
					ex.printStackTrace();
 
		}
 
	}
 
 
        /*************************************/
 
        /* This method takes two parameters: */
 
        /*  qMgr - a WMQ QueueManager object */
 
        /*  q    - a WMQ Queue object        */
 
        /*************************************/
 
	public void mPut(MQQueueManager qMgr, MQQueue q) {
 
		try {
 
 
			// Define a MQ message buffer
 
			MQMessage mBuf = new MQMessage();
 
 
			// create message options
 
			MQPutMessageOptions pmo = new MQPutMessageOptions();
 
			// accept defaults
 
			pmo.options = MQC.MQPMO_NONE; // use defaults
 
 
			System.out.println("Enter text to send, blank line to exit");
 
 
			InputStreamReader isr = new InputStreamReader(System.in);
 
			BufferedReader br = new BufferedReader(isr);
 
 
			String runShow;
 
			do {
 
				runShow = br.readLine();
 
				if (runShow.length() > 0) {
 
					mBuf.clearMessage();                // reset the buffer
 
					mBuf.correlationId = MQC.MQCI_NONE; // set correlationId
 
					mBuf.messageId = MQC.MQMI_NONE;     // set messageId
 
					mBuf.writeString(runShow);          // set actual message
 
					System.out.println("--> writing message to queue");
 
					q.put(mBuf, pmo);      // put the message out on the queue
 
				}
 
			} while (runShow.length() > 0);
 
 
		} catch (MQException ex) {
 
			System.out.println(
 
				"MQ exception occurred : Completion code "
 
					+ ex.completionCode
 
					+ " Reason code "
 
					+ ex.reasonCode);
 
		} catch (java.io.IOException ex) {
 
			System.out.println(
 
				"An error occurred reading from message buffer: " + ex);
 
		}
 
	}
 
} | 
			   
			 
		   | 
		
		
		  | Back to top | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | wschutz | 
		  
		    
			  
				 Posted: Sat Aug 26, 2006 3:07 am    Post subject:  | 
				     | 
			   
			 
		   | 
		
		
		    Jedi Knight
 
 Joined: 02 Jun 2005 Posts: 3316 Location: IBM (retired) 
  | 
		  
		    
			  
				
   
	| Quote: | 
   
  
	But when i comment MQEnvironment.hostname = "10.130.48.59", this program can run.
 
 | 
   
 
This means that you have a qmgr running on your machine and when you comment out hostname, you're connecting to that qmgr, instead of the qmgr on "10.130.48.59".  
 
 
What error are you getting?  If it's 2059, this means your program cannot connect to the remote qmgr.  Search here for 2059 and "client", this problem has literally been discussed in thousands of posts ....
 
 
good luck _________________ -wayne | 
			   
			 
		   | 
		
		
		  | Back to top | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | fjb_saper | 
		  
		    
			  
				 Posted: Sat Aug 26, 2006 6:22 am    Post subject:  | 
				     | 
			   
			 
		   | 
		
		
		    Grand High Poobah
 
 Joined: 18 Nov 2003 Posts: 20768 Location: LI,NY 
  | 
		  
		    
			  
				For a connection to a foreign qmgr you need a minimum of 3 things:
 
- host
 - port
 - channel
   Looks like you were missing the channel information...
 
And please read up in the Client Manual
 
 
Enjoy    _________________ MQ & Broker admin | 
			   
			 
		   | 
		
		
		  | Back to top | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | Kelvin | 
		  
		    
			  
				 Posted: Sat Aug 26, 2006 7:34 am    Post subject:  | 
				     | 
			   
			 
		   | 
		
		
		   Novice
 
 Joined: 25 Aug 2006 Posts: 10 Location: Hong Kong 
  | 
		  
		    
			  
				Sorry for my typo
 
 
But when i comment MQEnvironment.hostname = "10.130.48.59", this program CANNOT run. 
 
 
I am new to use MQ.  I want more detail
 
 
I specify the host, port and channel (like below) but still doesn't work.
 
 
MQEnvironment.hostname = "10.130.48.59"; 
 
MQEnvironment.port = 1414; 
 
MQEnvironment.CCSID = "MQ_APPLE.MQ_ORANGE"; 
 
 
Please kindly tell me how to do or tell me the link to find the solution
 
 
Many thanks
 
 
Rgs
 
 
Kelvin ho | 
			   
			 
		   | 
		
		
		  | Back to top | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | jefflowrey | 
		  
		    
			  
				 Posted: Sat Aug 26, 2006 7:40 am    Post subject:  | 
				     | 
			   
			 
		   | 
		
		
		   Grand Poobah
 
 Joined: 16 Oct 2002 Posts: 19981
  
  | 
		  
		    
			  
				
   
	| Kelvin wrote: | 
   
  
	| this program CANNOT run.  | 
   
 
 
 
What does this mean?  What does it do when you include this line? _________________ I am *not* the model of the modern major general. | 
			   
			 
		   | 
		
		
		  | Back to top | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | fjb_saper | 
		  
		    
			  
				 Posted: Sat Aug 26, 2006 9:58 am    Post subject:  | 
				     | 
			   
			 
		   | 
		
		
		    Grand High Poobah
 
 Joined: 18 Nov 2003 Posts: 20768 Location: LI,NY 
  | 
		  
		    
			  
				
   
	| Kelvin wrote: | 
   
  
	Sorry for my typo
 
 
But when i comment MQEnvironment.hostname = "10.130.48.59", this program CANNOT run. 
 
 
I am new to use MQ.  I want more detail
 
 
I specify the host, port and channel (like below) but still doesn't work.
 
 
MQEnvironment.hostname = "10.130.48.59"; 
 
MQEnvironment.port = 1414; 
 
MQEnvironment.CCSID = "MQ_APPLE.MQ_ORANGE"; 
 
 
Please kindly tell me how to do or tell me the link to find the solution
 
 
Many thanks
 
 
Rgs
 
 
Kelvin ho | 
   
 
 
CCSID is Coded Character Set ID and has nothing to do with the channel.
 
Not all channels are suitable for a client connection.
 
READ the Client Connection Manual       _________________ MQ & Broker admin | 
			   
			 
		   | 
		
		
		  | Back to top | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | Kelvin | 
		  
		    
			  
				 Posted: Sun Aug 27, 2006 7:24 pm    Post subject:  | 
				     | 
			   
			 
		   | 
		
		
		   Novice
 
 Joined: 25 Aug 2006 Posts: 10 Location: Hong Kong 
  | 
		  
		    
			  
				Please don't angry
 
 
My program is work when i comment 
 
 
//                    MQEnvironment.hostname = "127.0.0.1";
 
                       MQEnvironment.port = 1414;
 
                       MQEnvironment.channel = "QM_APPLE.QM_ORANGE";
 
                       MQEnvironment.CCSID = 437;
 
 
but when i take out the comment (like below), then failed with MQJE011: Sockedt connection attempt refused.
 
 
                      MQEnvironment.hostname = "127.0.0.1";
 
                       MQEnvironment.port = 1414;
 
                       MQEnvironment.channel = "QM_APPLE.QM_ORANGE";
 
                       MQEnvironment.CCSID = 437;
 
 
I wonder to know the reason.  How do i solve it? Oue use AD (WIN) for our network.
 
 
My machine is win-xp
 
 
Please let me know if you want more info.  Thanks
 
 
Rgs
 
 
Kelvin | 
			   
			 
		   | 
		
		
		  | Back to top | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | fjb_saper | 
		  
		    
			  
				 Posted: Sun Aug 27, 2006 8:15 pm    Post subject:  | 
				     | 
			   
			 
		   | 
		
		
		    Grand High Poobah
 
 Joined: 18 Nov 2003 Posts: 20768 Location: LI,NY 
  | 
		  
		    
		   | 
		
		
		  | Back to top | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | Kelvin | 
		  
		    
			  
				 Posted: Mon Aug 28, 2006 4:03 am    Post subject:  | 
				     | 
			   
			 
		   | 
		
		
		   Novice
 
 Joined: 25 Aug 2006 Posts: 10 Location: Hong Kong 
  | 
		  
		    
			  
				I got the document.  
 
 
My problem is not solved yet but I may find some Hint now.
 
 
Below is my code
 
 
MQEnvironment.hostname = "10.130.48.59";
 
MQEnvironment.port = 1414;
 
MQEnvironment.channel = "SYSTEM.DEF.SVRCONN";
 
MQEnvironment.CCSID = 1208;
 
 
When the channel type is Sender, then failed with below message
 
 
MQJE001: An MQException occurred: completion Code 2, Reason 2009
 
MQJE016: MQ queue manager closed channel immediately during connect Closure reason = 2009
 
 
When the channel type is Service-connection channel.  It WORK    
 
 
I thought the channel type cannot be "Sender".
 
 
Correct me if I am wrong.
 
 
Thanks 
 
 
Rgs
 
Kelvin    | 
			   
			 
		   | 
		
		
		  | Back to top | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | jefflowrey | 
		  
		    
			  
				 Posted: Mon Aug 28, 2006 4:04 am    Post subject:  | 
				     | 
			   
			 
		   | 
		
		
		   Grand Poobah
 
 Joined: 16 Oct 2002 Posts: 19981
  
  | 
		  
		    
			  
				
 _________________ I am *not* the model of the modern major general. | 
			   
			 
		   | 
		
		
		  | Back to top | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | garonne | 
		  
		    
			  
				 Posted: Mon Aug 28, 2006 5:40 am    Post subject:  | 
				     | 
			   
			 
		   | 
		
		
		   Acolyte
 
 Joined: 26 Jan 2006 Posts: 59
  
  | 
		  
		    
			  
				
   
	| Kelvin wrote: | 
   
  
	
 
Service-connection channel
 
 | 
   
 
 
 
I think it would be "Server connection channel". | 
			   
			 
		   | 
		
		
		  | Back to top | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | 
		    
		   |