You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

WildFly 10远程EJB查找遇java.io.IOException: Connection reset by peer问题求助

Fixing "java.io.IOException: Connection reset by peer" in WildFly 10 Remote EJB Lookup

Hey there, let's work through this connection reset error you're facing when trying to do a remote EJB lookup on WildFly 10. I've debugged similar issues a few times, so here are actionable steps to diagnose and fix the problem:

1. Complete Your Connection Configuration

Your code cuts off at the remote.connectionprovider.create.options.org.xnio... line, and this section is critical for establishing a valid connection to the server. Here's what you need to add to make the configuration complete:

private static Object lookup() throws Exception {
    Properties properties = new Properties();
    properties.put("java.naming.factory.url.pkgs", "org.jboss.ejb.client.naming");
    // Switch this to true to enable a dedicated EJB naming context (often fixes context initialization issues)
    properties.put("jboss.naming.client.ejb.context", "true");
    properties.put("org.jboss.ejb.client.scoped.context", "true");
    properties.put("endpoint.name", "client-endpoint");
    
    // XNIO connection provider settings
    properties.put("remote.connectionprovider.create.options.org.xnio.Options.SSL_ENABLED", "false");
    // Define your remote connection alias
    properties.put("remote.connections", "default");
    // Replace with your WildFly server's actual IP/hostname
    properties.put("remote.connection.default.host", "your-server-ip");
    // Use 8080 for HTTP remoting or 4447 for native remoting (check your server config)
    properties.put("remote.connection.default.port", "8080");
    
    // Uncomment if your server requires authentication
    // properties.put("remote.connection.default.username", "ejb-user");
    // properties.put("remote.connection.default.password", "ejb-password");
    
    InitialContext context = new InitialContext(properties);
    // Replace with your EJB's actual JNDI name (check server logs for the correct binding)
    return context.lookup("java:global/your-app-name/your-ejb-class!com.your.package.YourRemoteInterface");
}

2. Verify WildFly Server Configuration

  • Check Remote Connectors: Open your WildFly's standalone.xml (or domain.xml for domain mode) and ensure the remoting subsystem has a valid connector. Look for this section:
    <subsystem xmlns="urn:jboss:domain:remoting:3.0">
        <endpoint worker="default"/>
        <http-connector name="http-remoting-connector" connector-ref="default" security-realm="ApplicationRealm"/>
    </subsystem>
    
    This enables HTTP-based remoting on port 8080 (matching the client config above). If you prefer native remoting, use a remoting-connector on port 4447.
  • Confirm EJB Deployment: Check the WildFly server logs for lines like JNDI bindings for session bean named YourBean in deployment unit deployment "your-app.war". This will give you the exact JNDI name to use in your lookup code.

3. Rule Out Network/Firewall Issues

  • Test Connectivity: Use telnet your-server-ip 8080 (or your configured port) from the client machine. If the connection fails, your firewall or network security group is blocking traffic to that port. Open the port on both the server's firewall and any intermediate networks.
  • Check Server Binding: Ensure WildFly isn't only bound to localhost. In standalone.xml, verify the default socket binding uses a public IP or 0.0.0.0 instead of 127.0.0.1:
    <socket-binding-group name="standard-sockets" default-interface="public" port-offset="${jboss.socket.binding.port-offset:0}">
        <socket-binding name="http" port="${jboss.http.port:8080}"/>
        <!-- Other bindings -->
    </socket-binding-group>
    

4. Validate Client Dependencies

Make sure your client project has the correct WildFly EJB client dependencies (no outdated JBoss AS jars!). For Maven, add this to your pom.xml:

<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>org.wildfly</groupId>
            <artifactId>wildfly-ejb-client-bom</artifactId>
            <version>10.1.0.Final</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
    </dependencies>
</dependencyManagement>

<dependencies>
    <dependency>
        <groupId>org.jboss.ejb-client</groupId>
        <artifactId>jboss-ejb-client</artifactId>
    </dependency>
</dependencies>

5. Check for Additional Server-Side Errors

If the above steps don't fix it, look at the WildFly server logs (in standalone/log/server.log) for any errors when the client tries to connect. Common issues include:

  • Invalid authentication credentials (if security is enabled)
  • Missing EJB remote interface annotations
  • Deployment failures of your EJB module

内容的提问来源于stack exchange,提问作者subbu royal

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.21 07:28:27