SMPP错误代码61,62

时间:2011-02-27 09:16:34

标签: smpp

我正在使用jsmpp lib发送短信。 SMSC中心返回负面响应,如61,62,这是无效的预定交付时间和无效的有效期值。在与SMSC支持人员交谈之后,他们需要在jsmpp网站上进行一些搜索后找不到要传递的邮件的默认超时。谢谢你有什么建议吗?

3 个答案:

答案 0 :(得分:2)

根据SMPP标准,应该可以将这两个都留空,但如果需要有效期,则可以是绝对日期或相对日期。

格式应为YYMMDDhhmmsstnnp,其中

YY是两位数年份(00-99)

MM是月(01-12)

DD是白天(01-31)

hh是小时(00-23)

mm是分钟(00-59)

ss是秒(00-59)

t是十分之一秒(00-59)

nn是当地时间与UTC(00-48)之间的四分之一小时的时差

p可以是以下之一: - '+'当地时间早于UTC。 ' - '当地时间落后于UTC。 'R'这是相对时间。

因此,要使用相对时间使有效期为1小时,请使用以下内容:“000000010000000R”

答案 1 :(得分:2)

在我的项目中,我没有业务要求来安排交货时间和设置有效期,所以我将它们设置为空并且工作正常:-)

我使用此类从属性文件加载smpp配置。将使用它的代码看起来更易读和简单:-)

SMPPConfigManager是此类的接口。不仅可以从属性文件中读取此配置。例如,从Db开始,您可以在新类中实现此接口。

package ru.rodin.denis.smpp;

import java.util.Properties;
import org.jsmpp.bean.*;

/**
*
* @author Denis Rodin
*/
public class SMPPFileConfig implements SMPPConfigManager {

private String host;
private int port;
private String systemId;
private String password;
private String systemType;
private TypeOfNumber sourceAddrTon;
private TypeOfNumber destAddrTon;
private NumberingPlanIndicator sourceAddrNpi;
private NumberingPlanIndicator destAddrNpi;
private String addressRange;
private int connectTimeout;
private long reconnectInterval;
private String sourceAddr;
private String destinationAddr;
private SMSCDeliveryReceipt deliveryReceipt;
private RegisteredDelivery registeredDelivery;
private BindType bindType;
private ESMClass esmClass;
private byte protocolId;
private byte priorityFlag;
private String scheduleDeliveryTime;
private String validityPeriod;
private byte replaceIfPresentFlag;
private GeneralDataCoding generalDataCoding;
private boolean generalDataCoding_compressed = true;
private boolean generalDataCoding_containMessageClass = true;
private MessageClass generalDataCoding_messageClass = MessageClass.CLASS1;
private Alphabet generalDataCoding_alphabet = Alphabet.ALPHA_DEFAULT;
private byte smDefaultMsgId;
private long transactionTimer;
private int enquireLinkTimer;

public SMPPFileConfig(Properties prop) {
    this.host = prop.getProperty("smpp.host");
    this.port = Integer.parseInt(prop.getProperty("smpp.port"));
    this.systemId = prop.getProperty("smpp.systemId");
    this.password = prop.getProperty("smpp.password");
    this.systemType = prop.getProperty("smpp.systemType");
    this.sourceAddrTon = getTypeOfNumber(SMPPConfigManager.AddrTon.SOURCE, prop);
    this.destAddrTon = getTypeOfNumber(SMPPConfigManager.AddrTon.DEST, prop);
    this.sourceAddrNpi = getNumberingPlanIndicator(SMPPConfigManager.AddrNpi.SOURCE, prop);
    this.destAddrNpi = getNumberingPlanIndicator(SMPPConfigManager.AddrNpi.DEST, prop);
    this.addressRange = prop.getProperty("smpp.addressRange");
    this.connectTimeout = Integer.parseInt(prop.getProperty("smpp.connect.timeout"));
    this.reconnectInterval = Long.parseLong(prop.getProperty("smpp.reconnect.interval"));
    this.sourceAddr = prop.getProperty("smpp.sourceAddr");
    this.destinationAddr = null;
    this.deliveryReceipt = getSMSCDeliveryReceipt(prop.getProperty("smpp.SMSC.delivery.receipt"));
    this.registeredDelivery = new RegisteredDelivery(deliveryReceipt);
    this.bindType = getBindTypeFromProp(prop.getProperty("smpp.bindType"));
    this.esmClass = createESMClass(prop.getProperty("smpp.ESMClass.MessageMode"), prop.getProperty("smpp.ESMClass.MessageType"), prop.getProperty("smpp.ESMClass.GSMSpecificFeature"));
    this.protocolId = new Byte(prop.getProperty("smpp.protocolId"));
    this.priorityFlag = new Byte(prop.getProperty("smpp.priorityFlag"));
    this.scheduleDeliveryTime = prop.getProperty("smpp.scheduleDeliveryTime");
    this.validityPeriod = prop.getProperty("smpp.validityPeriod");
    this.replaceIfPresentFlag = new Byte(prop.getProperty("smpp.replaceIfPresentFlag"));
    this.generalDataCoding = new GeneralDataCoding(generalDataCoding_compressed, generalDataCoding_containMessageClass, generalDataCoding_messageClass, generalDataCoding_alphabet);
    this.smDefaultMsgId = new Byte(prop.getProperty("smpp.smDefaultMsgId"));
    this.transactionTimer = Long.parseLong(prop.getProperty("smpp.transactionTimer"));
    this.enquireLinkTimer = Integer.parseInt(prop.getProperty("smpp.enquireLinkTimer"));
}

@Override
public String toString() {
    return "SMPPFileConfig{" + "host=" + host + ", port=" + port + ", systemId=" + systemId + ", password=" + password + ", systemType=" + systemType + ", sourceAddrTon=" + sourceAddrTon + ", destAddrTon=" + destAddrTon + ", sourceAddrNpi=" + sourceAddrNpi + ", destAddrNpi=" + destAddrNpi + ", addressRange=" + addressRange + ", connectTimeout=" + connectTimeout + ", reconnectInterval=" + reconnectInterval + ", sourceAddr=" + sourceAddr + ", destinationAddr=" + destinationAddr + ", deliveryReceipt=" + deliveryReceipt + ", registeredDelivery=" + registeredDelivery + ", bindType=" + bindType + ", esmClass=" + esmClass + ", protocolId=" + protocolId + ", priorityFlag=" + priorityFlag + ", scheduleDeliveryTime=" + scheduleDeliveryTime + ", validityPeriod=" + validityPeriod + ", replaceIfPresentFlag=" + replaceIfPresentFlag + ", generalDataCoding=" + generalDataCoding + ", generalDataCoding_compressed=" + generalDataCoding_compressed + ", generalDataCoding_containMessageClass=" + generalDataCoding_containMessageClass + ", generalDataCoding_messageClass=" + generalDataCoding_messageClass + ", generalDataCoding_alphabet=" + generalDataCoding_alphabet + ", smDefaultMsgId=" + smDefaultMsgId + '}';
}

@Override
public String getAddressRange() {
    return addressRange;
}

@Override
public int getConnectTimeout() {
    return connectTimeout;
}

@Override
public SMSCDeliveryReceipt getDeliveryReceipt() {
    return deliveryReceipt;
}

@Override
public RegisteredDelivery getRegisteredDelivery() {
    return registeredDelivery;
}

@Override
public NumberingPlanIndicator getDestAddrNpi() {
    return destAddrNpi;
}

@Override
public TypeOfNumber getDestAddrTon() {
    return destAddrTon;
}

@Override
public void setDestinationAddr(String destinationAddr) {
    this.destinationAddr = destinationAddr;
}

@Override
public String getDestinationAddr() {
    return destinationAddr;
}

@Override
public String getHost() {
    return host;
}

@Override
public String getPassword() {
    return password;
}

@Override
public int getPort() {
    return port;
}

@Override
public long getReconnectInterval() {
    return reconnectInterval;
}

@Override
public String getSourceAddr() {
    return sourceAddr;
}

@Override
public NumberingPlanIndicator getSourceAddrNpi() {
    return sourceAddrNpi;
}

@Override
public TypeOfNumber getSourceAddrTon() {
    return sourceAddrTon;
}

@Override
public String getSystemId() {
    return systemId;
}

@Override
public String getSystemType() {
    return systemType;
}

@Override
public BindType getBindType() {
    return bindType;
}

@Override
public ESMClass getESMClass() {
    return esmClass;
}

@Override
public void setESMClass(ESMClass esmClass) {
    this.esmClass = esmClass;
}

@Override
public byte getProtocolId() {
    return protocolId;
}

@Override
public byte getPriorityFlag() {
    return priorityFlag;
}

@Override
public String getScheduleDeliveryTime() {
    return scheduleDeliveryTime;
}

@Override
public String getValidityPeriod() {
    return validityPeriod;
}

@Override
public byte getReplaceIfPresentFlag() {
    return replaceIfPresentFlag;
}

@Override
public GeneralDataCoding getGeneralDataCoding() {
    return generalDataCoding;
}

@Override
public byte getsmDefaultMsgId(){
    return smDefaultMsgId;
}

@Override
public long getTransactionTimer()
{
    return transactionTimer;
}

@Override
public int getEnquireLinkTimer()
{
    return enquireLinkTimer;
}

private ESMClass createESMClass(String messageMode, String messageType, String GSMSpecificFeature) {
    return new ESMClass(getESMClassMessageMode(messageMode), getESMMessageType(messageType), getESMGSMSpecificFeature(GSMSpecificFeature));
}

private MessageMode getESMClassMessageMode(String type) {
    if (type.equals("DEFAULT")) {
        return MessageMode.DEFAULT;
    } else if (type.equals("DATAGRAM")) {
        return MessageMode.DATAGRAM;
    } else if (type.equals("STORE_AND_FORWARD")) {
        return MessageMode.STORE_AND_FORWARD;
    } else if (type.equals("TRANSACTION")) {
        return MessageMode.TRANSACTION;
    } else {
        return null;
    }
}

private MessageType getESMMessageType(String type) {
    if (type.equals("DEFAULT")) {
        return MessageType.DEFAULT;
    } else if (type.equals("CONV_ABORT")) {
        return MessageType.CONV_ABORT;
    } else if (type.equals("ESME_DEL_ACK")) {
        return MessageType.ESME_DEL_ACK;
    } else if (type.equals("ESME_MAN_ACK")) {
        return MessageType.ESME_MAN_ACK;
    } else if (type.equals("INTER_DEL_NOTIF")) {
        return MessageType.INTER_DEL_NOTIF;
    } else if (type.equals("SME_DEL_ACK")) {
        return MessageType.SME_DEL_ACK;
    } else if (type.equals("SME_MAN_ACK")) {
        return MessageType.SME_MAN_ACK;
    } else if (type.equals("SMSC_DEL_RECEIPT")) {
        return MessageType.SMSC_DEL_RECEIPT;
    } else {
        return null;
    }

}

private GSMSpecificFeature getESMGSMSpecificFeature(String type) {
    if (type.equals("DEFAULT")) {
        return GSMSpecificFeature.DEFAULT;
    } else if (type.equals("REPLYPATH")) {
        return GSMSpecificFeature.REPLYPATH;
    } else if (type.equals("UDHI")) {
        return GSMSpecificFeature.UDHI;
    } else if (type.equals("UDHI_REPLYPATH")) {
        return GSMSpecificFeature.UDHI_REPLYPATH;
    } else {
        return null;
    }
}

private BindType getBindTypeFromProp(String type) {
    //String type = prop.getProperty("smpp.bindType");
    if (type.equals("BIND_RX")) {
        return BindType.BIND_RX;
    } else if (type.equals("BIND_TX")) {
        return BindType.BIND_TX;
    } else if (type.equals("BIND_TRX")) {
        return BindType.BIND_TRX;
    } else {
        return null;
    }
}

private TypeOfNumber getTypeOfNumber(SMPPConfigManager.AddrTon ton, Properties prop) {
    String type;
    if (ton == SMPPConfigManager.AddrTon.SOURCE) {
        type = prop.getProperty("smpp.sourceAddrTon");
    } else {
        type = prop.getProperty("smpp.destAddrTon");
    }

    if (type.equals("ABBREVIATED")) {
        return TypeOfNumber.ABBREVIATED;
    } else if (type.equals("ALPHANUMERIC")) {
        return TypeOfNumber.ALPHANUMERIC;
    } else if (type.equals("INTERNATIONAL")) {
        return TypeOfNumber.INTERNATIONAL;
    } else if (type.equals("NATIONAL")) {
        return TypeOfNumber.NATIONAL;
    } else if (type.equals("NETWORK_SPECIFIC")) {
        return TypeOfNumber.NETWORK_SPECIFIC;
    } else if (type.equals("SUBSCRIBER_NUMBER")) {
        return TypeOfNumber.SUBSCRIBER_NUMBER;
    } else if (type.equals("UNKNOWN")) {
        return TypeOfNumber.UNKNOWN;
    } else {
        return null;
    }
}

private SMSCDeliveryReceipt getSMSCDeliveryReceipt(String type) {
    //String type = prop.getProperty("smpp.SMSC.delivery.receipt");

    if (type.equals("DEFAULT")) {
        return SMSCDeliveryReceipt.DEFAULT;
    } else if (type.equals("SUCCESS")) {
        return SMSCDeliveryReceipt.SUCCESS;
    } else if (type.equals("SUCCESS_FAILURE")) {
        return SMSCDeliveryReceipt.SUCCESS_FAILURE;
    } else {
        return null;
    }
}

private NumberingPlanIndicator getNumberingPlanIndicator(SMPPConfigManager.AddrNpi npi, Properties prop) {

    String type;
    if (npi == SMPPConfigManager.AddrNpi.SOURCE) {
        type = prop.getProperty("smpp.sourceAddrNpi");
    } else {
        type = prop.getProperty("smpp.destAddrNpi");
    }

    if (type.equals("DATA")) {
        return NumberingPlanIndicator.DATA;
    } else if (type.equals("ERMES")) {
        return NumberingPlanIndicator.ERMES;
    } else if (type.equals("INTERNET")) {
        return NumberingPlanIndicator.INTERNET;
    } else if (type.equals("ISDN")) {
        return NumberingPlanIndicator.ISDN;
    } else if (type.equals("LAND_MOBILE")) {
        return NumberingPlanIndicator.LAND_MOBILE;
    } else if (type.equals("NATIONAL")) {
        return NumberingPlanIndicator.NATIONAL;
    } else if (type.equals("PRIVATE")) {
        return NumberingPlanIndicator.PRIVATE;
    } else if (type.equals("TELEX")) {
        return NumberingPlanIndicator.TELEX;
    } else if (type.equals("WAP")) {
        return NumberingPlanIndicator.WAP;
    } else if (type.equals("UNKNOWN")) {
        return NumberingPlanIndicator.UNKNOWN;
    } else {
        return null;
    }
}
}

答案 2 :(得分:1)

当您按计划交付时间提交当前时间时,可能会发生此错误。因为发送请求需要一些时间。所以你提到的时间可能已经过去。所以将预定的交货时间设置为(当前时间+10秒)

    long TEN_SECONDS=10000;//millisecs

    Calendar date = Calendar.getInstance();
    long t= date.getTimeInMillis();
    Date scheduleDeliveryTime=new Date(t + (   TEN_SECONDS));