gpt4 book ai didi

java.rmi.ConnectException : Connection refused to host: 192. 168.0.55

转载 作者:行者123 更新时间:2023-12-02 04:55:31 38 4
gpt4 key购买 nike

我是 NetBeans 和 Java 的初学者,所以我很确定我的问题非常基本,但我花了 2 周时间试图找到解决方案,但我完全陷入困境

这就是问题:

我想实现一个 RMI 服务器客户端应用程序因此,第一步是尝试使用 NetBeans 从网络上完成一项工作

我使用了oracle教程来实现第一部分 http://docs.oracle.com/javase/tutorial/rmi/server.html

我的问题不是客户端连接不上,而是服务器连我给他的端口都注册不了。错误信息中的IP是我的私有(private)IP。

这是我收到的错误消息:

Conectando a:  127.0.0.1 / 19400 / PlanificadorTalsa
ServidorPlanificadorStarter exception:
java.rmi.ConnectException: Connection refused to host: 192.168.0.55; nested exception is:
java.net.ConnectException: Connection refused: connect
at sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:619)
at sun.rmi.transport.tcp.TCPChannel.createConnection(TCPChannel.java:216)
at sun.rmi.transport.tcp.TCPChannel.newConnection(TCPChannel.java:202)
at sun.rmi.server.UnicastRef.newCall(UnicastRef.java:342)
at sun.rmi.registry.RegistryImpl_Stub.rebind(Unknown Source)
at Starter.ServidorPlanificadorStarter.main(ServidorPlanificadorStarter.java:52)
Caused by: java.net.ConnectException: Connection refused: connect
at java.net.DualStackPlainSocketImpl.connect0(Native Method)
at java.net.DualStackPlainSocketImpl.socketConnect(DualStackPlainSocketImpl.java:79)
at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:345)
at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:172)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
at java.net.Socket.connect(Socket.java:589)
at java.net.Socket.connect(Socket.java:538)
at java.net.Socket.<init>(Socket.java:434)
at java.net.Socket.<init>(Socket.java:211)
at sun.rmi.transport.proxy.RMIDirectSocketFactory.createSocket(RMIDirectSocketFactory.java:40)
at sun.rmi.transport.proxy.RMIMasterSocketFactory.createSocket(RMIMasterSocketFactory.java:148)
at sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:613)
... 5 more

我运行的是 Windows 8.1,并禁用了防火墙。我还使用授予所有权限的安全文件

这是我从 NetBeans 执行的 java 代码:

import Conexion.DatosConexion;
import Servidor.*;

import java.rmi.RemoteException;
import java.rmi.registry.LocateRegistry;
import java.rmi.registry.Registry;
import java.rmi.server.UnicastRemoteObject;

public class ServidorPlanificadorStarter implements InterfazServidorPlanificador {

private static String ip;
private static String Servidor = "SERVIDORNUBE";
private static int puerto;
private static String nombreServidor;

public ServidorPlanificadorStarter(){
super();
}

public static void main(String[] args) {
if (System.getSecurityManager() == null) {
System.setSecurityManager(new SecurityManager());
}
try {
DatosConexion datos = DatosConexion.getInstance();

ip = datos.getServiceIP(Servidor);
puerto = Integer.valueOf(datos.getServicePort(Servidor));
nombreServidor = datos.getServiceName(Servidor);

System.setProperty("java.rmi.server.hostname", ip);

System.out.println("Conectando a: " + ip + " / " + puerto + " / " + nombreServidor);

InterfazServidorPlanificador engine = new ServidorPlanificadorStarter();
InterfazServidorPlanificador stub =
(InterfazServidorPlanificador) UnicastRemoteObject.exportObject(engine, puerto);
Registry registry = LocateRegistry.getRegistry();
registry.rebind(nombreServidor, stub);
System.out.println("ServidorPlanificador bound");
} catch (Exception e) {
System.err.println("ServidorPlanificadorStarter exception:");
e.printStackTrace();
}
}

}

界面如下(非常基本,因为我没有做任何事情)

public interface InterfazServidorPlanificador extends Remote {

//void addObserver(RemoteObserver o) throws RemoteException;

}

最佳答案

您是否按照教程启动了 RMI 注册表? http://docs.oracle.com/javase/tutorial/rmi/running.html

关于java.rmi.ConnectException : Connection refused to host: 192. 168.0.55,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28808512/

38 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com