系统很简单 ,有个线程不停的跑从数据库中读出数据,调联通的接口发短信
但是放哪里跑2,3天就会报:
java.lang.IllegalStateException: 登录不成功:其它错误
at com.huawei.smproxy.SGIPSMProxy.connect(SGIPSMProxy.java:72)重启应用就又可以登录了.........  我怀疑代码是不是哪里有问题(smproxy.jar)???? 
一下是调联通接口的代码,线程没隔一分钟调用一次getInstance()方法. public static ZxsSGIPSMProxy sgipProxy = null;/**
  * 用SGIP长连接发送联通短信
  * 
  * @param mobile
  * @param content
  * @return 1提交短信失败 0提交短信成功
  */
private static int sendUnicomMsgBySGIP(String content, String mobile, String serviceCode) {
  byte[] contentByte = null;
  try {
   contentByte = content.getBytes("GBK");// 统一处理为汉字
  } catch (UnsupportedEncodingException e) {
   e.printStackTrace();
   return 1;
  }
  String[] mobiles = new String[] { mobile };
  
  SGIPSubmitMessage msg = new SGIPSubmitMessage(serviceCode, // SPNumber
    "000000000000000000000", // ChargeNumber
    mobiles, // UserNumber
    "99999", // CorpId
    "SHGRP", // ServiceType
    0, // 1, //FeeType
    "0", // "100", //FeeValue
    "0", // "100", //GivenValue
    0, // AgentFlag
    2, // 0, //MorelatetoMTFlag
    0, // Priority
    null, // ExpireTime
    null, // ScheduleTime
    1, // 3, //ReportFlag
    0, // 1, //TP_pid
    0, // 1, //TP_udhi
    15, // MessageCoding(15为GBK编码;0为ASCII码;8为UCS2编码)
    0, // MessageType
    contentByte.length, // MessageLength
    contentByte, // MessageContent
    "" // reserve
  );
  SGIPMessage resp = null;
  try {
   log.debug("getConn: "+sgipProxy.getConn()+"  ,getConnState: "+sgipProxy.getConnState()+"   ,sgipProxy: "+sgipProxy);
   resp = sgipProxy.send(msg);
   log.debug(resp + ",=======time:" + msg.getTimeStamp()
     + ",srcnod:" + msg.getSrcNodeId() + "cmdId"
     + msg.getCommandId());
   if(resp == null) {
    log.error("联通提交短信失败111!!!!!!!!!!!!!!!!!!!!!!!!!!");
    reConn();
    return 1;
   }
  } catch (IOException e1) {
   sgipProxy.close();
   log.error("联通提交短信失败2222!!!!!!!!!!!!!!!!!!!!!!!!!!");
   log.error(e1.getMessage());
   log.error("尝试重新连接!!!!!!!!!!!!!!!!!!!!!!!!!!");
   getInstance();
   return 1;
  }
  return 0;
}
public static void getInstance() {
  if(sgipProxy==null || sgipProxy.getConnState()!=null) {
   try {
    String accountId = Constant.SMS_CHINAUNICOM_ACCOUNTID; // 服务登录名
    String password = Constant.SMS_CHINAUNICOM_PASSWORD; // 服务登录密码
    
    log.debug("开始连接联通接口:>>>>>>>>>>>>>>>>>"+accountId+" "+" "+password);
    
    SimpleDateFormat formatter = new java.text.SimpleDateFormat(
      "yyyy-MM-dd HH:mm:ss");
    Args ag = null;
    sgipProxy = null;
    try {
     log.debug("=======================11111aaaa========================");
     ag = new Cfg(Constant.LTConfig, true).getArgs("SGIPConnect");
     log.debug("=======================11111========================: " 
       + ag.get("host", new String())
       + ag.get("port", new String())
       + ag.get("transaction-timeout", new String())
       + ag.get("read-timeout", new String())
       + ag.get("source-addr", new String())
       + ag.get("version", new String())
       + ag.get("sequence-number", new String())
       + ag.get("debug", new String()));
     log.debug("=======================11111bbbb========================");
    } catch (IOException e) {
     log.error("读取配置文件失败!!!!!!!!!!!!!!!!!!!!!!!");
     log.error(e.getMessage());
     e.printStackTrace();
    }
    log.debug("=======================222222========================");
    sgipProxy = new ZxsSGIPSMProxy(ag);
    log.debug("=======================333333========================");
    boolean isUnicomCon = sgipProxy.connect(accountId, password);
    log.debug("=======================444444========================");
    if (isUnicomCon)
     log.debug("成功登陆时间:"
       + formatter.format(Calendar.getInstance().getTime()));
    log.debug("=======================555555========================");
   } catch (Exception e2) {
    sgipProxy.close();
    log.error("联通接口连接失败!!!!!!!!!!!!!!!!!!!!!!!");
    log.error(e2.getMessage(),e2);
    log.error(e2.getMessage());
    e2.printStackTrace();
   }
  }
}private static void reConn() {
  try {
   log.debug("=======================reConn========================");
   sgipProxy.close();
   String accountId = Constant.SMS_CHINAUNICOM_ACCOUNTID; // 服务登录名
   String password = Constant.SMS_CHINAUNICOM_PASSWORD; // 服务登录密码
   
   log.debug("开始连接联通接口:>>>>>>>>>>>>>>>>>"+accountId+" "+" "+password);
   
   SimpleDateFormat formatter = new java.text.SimpleDateFormat(
   "yyyy-MM-dd HH:mm:ss");
   Args ag = null;
   sgipProxy = null;
   try {
    log.debug("=======================11111aaaa========================");
    ag = new Cfg(Constant.LTConfig, true).getArgs("SGIPConnect");
    log.debug("=======================11111========================: " 
      + ag.get("host", new String())
      + ag.get("port", new String())
      + ag.get("transaction-timeout", new String())
      + ag.get("read-timeout", new String())
      + ag.get("source-addr", new String())
      + ag.get("version", new String())
      + ag.get("sequence-number", new String())
      + ag.get("debug", new String()));
    log.debug("=======================11111bbbb========================");
   } catch (IOException e) {
    log.error("读取配置文件失败!!!!!!!!!!!!!!!!!!!!!!!");
    log.error(e.getMessage());
    e.printStackTrace();
   }
   log.debug("=======================222222========================");
   sgipProxy = new ZxsSGIPSMProxy(ag);
   log.debug("=======================333333========================");
   boolean isUnicomCon = sgipProxy.connect(accountId, password);
   log.debug("=======================444444========================");
   if (isUnicomCon)
    log.debug("成功登陆时间:"
      + formatter.format(Calendar.getInstance().getTime()));
   log.debug("=======================555555========================");
   
  } catch (Exception e2) {
   sgipProxy.close();
   log.error("联通接口连接失败!!!!!!!!!!!!!!!!!!!!!!!");
   log.error(e2.getMessage(),e2);
   log.error(e2.getMessage());
   e2.printStackTrace();
  }
}
好像说是连接没有关闭而又去连接会报这个错   , 但是我在异常中已经关闭了连接才去重连的啊 . 谁有没有现成的代码给我参考下呢?