ASG
IBM
Zystems
Cressida
Icon
Netflexity
 
  MQSeries.net
Search  Search       Tech Exchange      Education      Certifications      Library      Info Center      SupportPacs      LinkedIn  Search  Search                                                                   FAQ  FAQ   Usergroups  Usergroups
 
Register  ::  Log in Log in to check your private messages
 
RSS Feed - WebSphere MQ Support RSS Feed - Message Broker Support

MQSeries.net Forum Index » IBM MQ Java / JMS » MQJE011: Socket connection attempt refused

Post new topic  Reply to topic
 MQJE011: Socket connection attempt refused « View previous topic :: View next topic » 
Author Message
Kelvin
PostPosted: Fri Aug 25, 2006 9:09 pm    Post subject: MQJE011: Socket connection attempt refused Reply with quote

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
View user's profile Send private message
wschutz
PostPosted: Sat Aug 26, 2006 3:07 am    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail AIM Address
fjb_saper
PostPosted: Sat Aug 26, 2006 6:22 am    Post subject: Reply with quote

Grand High Poobah

Joined: 18 Nov 2003
Posts: 20756
Location: LI,NY

For a connection to a foreign qmgr you need a minimum of 3 things:
  1. host
  2. port
  3. channel
Looks like you were missing the channel information...
And please read up in the Client Manual

Enjoy
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
Kelvin
PostPosted: Sat Aug 26, 2006 7:34 am    Post subject: Reply with quote

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
View user's profile Send private message
jefflowrey
PostPosted: Sat Aug 26, 2006 7:40 am    Post subject: Reply with quote

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
View user's profile Send private message
fjb_saper
PostPosted: Sat Aug 26, 2006 9:58 am    Post subject: Reply with quote

Grand High Poobah

Joined: 18 Nov 2003
Posts: 20756
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
View user's profile Send private message Send e-mail
Kelvin
PostPosted: Sun Aug 27, 2006 7:24 pm    Post subject: Reply with quote

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
View user's profile Send private message
fjb_saper
PostPosted: Sun Aug 27, 2006 8:15 pm    Post subject: Reply with quote

Grand High Poobah

Joined: 18 Nov 2003
Posts: 20756
Location: LI,NY

From your post it is obvious that
  • you do not understand what is happening i.e. why it works one way and not the other, or which qmgr you are connecting to
  • what channel to use

fjb_saper wrote:
Not all channels are suitable for a client connection

So again please read the manuals
http://publib.boulder.ibm.com/infocenter/wmqv6/v6r0/topic/com.ibm.mq.csqzaf.doc/csqzaf08.htm

_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
Kelvin
PostPosted: Mon Aug 28, 2006 4:03 am    Post subject: Reply with quote

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
View user's profile Send private message
jefflowrey
PostPosted: Mon Aug 28, 2006 4:04 am    Post subject: Reply with quote

Grand Poobah

Joined: 16 Oct 2002
Posts: 19981

fjb_saper wrote:
fjb_saper wrote:
Not all channels are suitable for a client connection

So again please read the manuals
http://publib.boulder.ibm.com/infocenter/wmqv6/v6r0/topic/com.ibm.mq.csqzaf.doc/csqzaf08.htm

_________________
I am *not* the model of the modern major general.
Back to top
View user's profile Send private message
garonne
PostPosted: Mon Aug 28, 2006 5:40 am    Post subject: Reply with quote

Acolyte

Joined: 26 Jan 2006
Posts: 59

Kelvin wrote:

Service-connection channel


I think it would be "Server connection channel".
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » IBM MQ Java / JMS » MQJE011: Socket connection attempt refused
Jump to:  



You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Protected by Anti-Spam ACP
 
 


Theme by Dustin Baccetti
Powered by phpBB © 2001, 2002 phpBB Group

Copyright © MQSeries.net. All rights reserved.