美文网首页
openoffice连接失败

openoffice连接失败

作者: 吹奏一池春水 | 来源:发表于2018-08-20 11:53 被阅读0次
    问题

    项目部署到新的测试环境后,执行word转pdf时连接失败报错

    java.net.ConnectException: connection failed: socket,host=localhost,port=8100,tcpNoDelay=1: java.net.ConnectException: Connection refused

    原因

    openoffice连接代码写法

    // 客户端连接
    OpenOfficeConnection connection = new SocketOpenOfficeConnection(8100);
    // 源码
    public class SocketOpenOfficeConnection extends AbstractOpenOfficeConnection {
        
        public static final String DEFAULT_HOST = "localhost";
        public static final int DEFAULT_PORT = 8100;
    
        public SocketOpenOfficeConnection() {
            this(DEFAULT_HOST, DEFAULT_PORT);
        }
    
        public SocketOpenOfficeConnection(int port) {
            this(DEFAULT_HOST, port);
        }
    
        public SocketOpenOfficeConnection(String host, int port) {
            super("socket,host=" + host + ",port=" + port + ",tcpNoDelay=1");
        }
    }
    

    由源码看出默认连接主机名是"localhost",之后查看服务器/etc/hosts并未配置127.0.0.1主机名为localhost

    解决方法

    方法一:在/etc/hosts中添加127.0.0.1对应主机名localhost配置
    方法二:客户端连接指定ip

    OpenOfficeConnection connection = new SocketOpenOfficeConnection("127.0.0.1", 8100);
    

    相关文章

      网友评论

          本文标题:openoffice连接失败

          本文链接:https://www.haomeiwen.com/subject/zdbkiftx.html