title: Websphere MQ issue while writing a message to queue from java program
body: <p>I am trying to put a message to Queue from a Java program, I am getting an issue where it says it unable to connect to the host &amp; it seems it is not able to read the channel.</p>
  
  <p>Here is the error from AMERR01.log</p>
  
  <pre><code>----- amqccita.c : 4113 -------------------------------------------------------
  07/25/2016 07:04:29 AM - Process(18280.26) User(mqm) Program(amqrmppa)
                      Host(ip-10-0-0-238) Installation(Installation1)
                      VRMF(8.0.0.4) QMgr(CSBTS.QUEUE.MANAGER)
  
  AMQ9209: Connection to host 'ip-10-0-0-238 (10.0.0.238)' for channel 'CHAN2'
  closed.
  
  EXPLANATION:
  An error occurred receiving data from 'ip-10-0-0-238 (10.0.0.238)' over TCP/IP.
   The connection to the remote host has unexpectedly terminated.
  
  The channel name is 'CHAN2'; in some cases it cannot be determined and so is
  shown as '????'.
  ACTION:
  Tell the systems administrator.
  </code></pre>
  
  <p>Here is the java code, </p>
  
  <pre><code>package com.sample.mq.client.ClientMQ;
  
  import java.io.IOException;
  
  import com.ibm.mq.MQC;
  import com.ibm.mq.MQEnvironment;
  import com.ibm.mq.MQException;
  import com.ibm.mq.MQGetMessageOptions;
  import com.ibm.mq.MQMessage;
  import com.ibm.mq.MQPutMessageOptions;
  import com.ibm.mq.MQQueue;
  import com.ibm.mq.MQQueueManager;
  
  /**
   * Java class to connect to MQ. Post and Retreive messages.
   *
   */
  public class MQClientTest {
  
      String qMngrStr = "CSBTS.QUEUE.MANAGER";
      String user = "mqm";
      String password = "bts@2016";
      String queueName = "CSBTS.DEAL";
      String hostName = "10.0.0.238";
      int port = 1414;
      String channel = "CHAN2";
      //message to put on MQ.
      String msg = "Hello World, WelCome to MQ.";
      //Create a default local queue.
      MQQueue defaultLocalQueue;
      MQQueueManager qManager;
  
      /**
       * Initialize the MQ
       *
       */
      public void init(){
  
          //Set MQ connection credentials to MQ Envorinment.
           MQEnvironment.hostname = hostname;
           MQEnvironment.channel = channel;
           MQEnvironment.port = port;
           MQEnvironment.userID = user;
           MQEnvironment.password = password;
           //set transport properties.
           MQEnvironment.properties.put(MQC.TRANSPORT_PROPERTY, MQC.TRANSPORT_MQSERIES_CLIENT);
  
           try {
               //initialize MQ manager.
              qManager = new MQQueueManager(qMngrStr);
          } catch (MQException e) {
              e.printStackTrace();
          }
      }
  
      /**
       * Method to put message to MQ.
       *
       */
      public void putAndGetMessage(){
  
          int openOptions = MQC.MQOO_INPUT_AS_Q_DEF | MQC.MQOO_OUTPUT; 
          try {
              defaultLocalQueue = qManager.accessQueue(queueName, openOptions);
  
              MQMessage putMessage = new MQMessage();
              putMessage.writeUTF(msg);
  
              //specify the message options...
              MQPutMessageOptions pmo = new MQPutMessageOptions(); 
              // accept 
              // put the message on the queue
              defaultLocalQueue.put(putMessage, pmo);
  
              System.out.println("Message is put on MQ.");
  
              //get message from MQ.
              MQMessage getMessages = new MQMessage();
              //assign message id to get message.
              getMessages.messageId = putMessage.messageId;
  
              //get message options.
              MQGetMessageOptions gmo = new MQGetMessageOptions();
              defaultLocalQueue.get(getMessages, gmo);
  
              String retreivedMsg = getMessages.readUTF();
              System.out.println("Message got from MQ: "+retreivedMsg);
  
          } catch (MQException e) {
              e.printStackTrace();
          } catch (IOException e) {
              e.printStackTrace();
          }
      }
  
      public static void main(String[] args) {
  
          System.out.println("Processing Main...");
  
          MQClientTest clientTest = new MQClientTest();
  
          //initialize MQ.
          clientTest.init();
  
          //put and retreive message from MQ.
          clientTest.putAndGetMessage();
  
          System.out.println("Done!");
      }
  
  }
  </code></pre>
  
  <p>I am trying to read the message from the queue from the command line,</p>
  
  <pre><code>./amqsget CSBTS.DEAL CSBTS.QUEUE.MANAGER
  </code></pre>
  
  <p>I am not able to figure out what is the problem, is it with the connection or channel.
  P.S My channel authentication is disabled.</p>