Gammu 同时使用两个或多个 Java 应用程序从 ssh 发送短信



我正在使用gammu发送短信,我想知道是否可以使用两台或多台带有java应用程序的计算机同时发送消息。我尝试了 10 次,10 次中的 10 次消息都成功从两台计算机发送。9次只有一台计算机可以发送短信,而另一台计算机无法发送。是否有某种设置或命令,以便我可以同时从两台计算机发送消息?对于配置,我使用 Gammu 的默认配置

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Properties;
import com.jcraft.jsch.ChannelExec;
import com.jcraft.jsch.JSch;
import com.jcraft.jsch.JSchException;
import com.jcraft.jsch.Session;
public class TestingSms {

public static void main(String[] args) {
        // TODO Auto-generated method stub
        String host = "MY GAMMU IP";
        String user = "MY USERNAME";
        String password = "MY PASSWORD";
        int port = 22;
        String sms ="haloo";
        JSch jsch = new JSch();
        try {
            Session session = jsch.getSession(user, host, port);
            session.setPassword(password);
            session.setConfig("StrictHostKeyChecking", "no");
            session.connect();
            ChannelExec exec = (ChannelExec) session.openChannel("exec");
            exec.setCommand("gammu sendsms TEXT 08xxxxxxxxxx -text ""+sms+""");
            exec.setErrStream(System.err);
            exec.connect();
            BufferedReader reader = new BufferedReader(new InputStreamReader(exec.getInputStream()));
            String temp;
            while((temp=reader.readLine())!=null) {
                System.out.println(temp);
            }
            exec.disconnect();
            session.disconnect();
            System.out.println("nnFinish");
        } catch (JSchException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }
}

失败消息:

Warning: No configuration read, using builtin defaults!
No response in specified timeout. Probably phone not connected.

提前谢谢你

也许你更愿意为此使用 Gammu SMSD - 它在服务器上运行并从/接收来自/发送到数据库的消息。这样,您只需将消息插入数据库即可轻松地从其他主机发送消息。

错误Warning: No configuration read, using builtin defaults!表明Gammu没有找到配置文件,也许您正在以其他用户身份运行它?或者尝试使用 --config 参数指定配置文件的路径。

相关内容

最新更新