Do I have to ditch Netty?

Post here your questions about SFS2X. Here we discuss all server-side matters. For client API questions see the dedicated forums.

Moderators: Lapo, Bax

User avatar
gabrielvpy
Posts: 69
Joined: 23 Jul 2015, 20:18

Do I have to ditch Netty?

Postby gabrielvpy » 15 Mar 2018, 13:59

In our game we've arrived to the point where we need multiple servers and I started working on a communication protocol between servers using netty. But I realised that SFS2X no longer supports netty. Should I use a different approach? All I need a the moment is to know if a server is alive and how many players are in that server.
We made an awesome GPS - MOBA.
Try it out here: Get Fhacktions
User avatar
Lapo
Site Admin
Posts: 22999
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Do I have to ditch Netty?

Postby Lapo » 15 Mar 2018, 15:07

Hi,
yes we have removed the Netty dependency because we now use Jetty 9.x as the websocket engine.
You can still use Netty for your own inter-communication, no problem :)

Cheers
Lapo
--
gotoAndPlay()
...addicted to flash games
User avatar
gabrielvpy
Posts: 69
Joined: 23 Jul 2015, 20:18

Re: Do I have to ditch Netty?

Postby gabrielvpy » 15 Mar 2018, 16:23

Ok, I'm goint to need your help here, Lapo.

I implemented the telnet server (http://netty.io/4.0/xref/io/netty/examp ... mmary.html) on my zone extension and the client elswhere.

It works as espected, I connect from the client and I get the responses. But genereted an unexpexted problem. SFS2X won't autoload my jar if I update mi zone extension jar. What could be causing that?

Here's my code.

Server side
In my Zone init()

Code: Select all

//Cluster server up
        try {
            ClusterServer clusterServer = new ClusterServer(this);
            clusterServer.init();
        } catch (Exception e) {
            e.printStackTrace();
        }


telnet server (3 classes)

Code: Select all

import com.fhacktions.zone.ZoneExtension;
import io.netty.bootstrap.ServerBootstrap;
import io.netty.channel.EventLoopGroup;
import io.netty.channel.nio.NioEventLoopGroup;
import io.netty.channel.socket.nio.NioServerSocketChannel;
import io.netty.handler.logging.LogLevel;
import io.netty.handler.logging.LoggingHandler;
import io.netty.handler.ssl.SslContext;
import io.netty.handler.ssl.SslContextBuilder;
import io.netty.handler.ssl.util.SelfSignedCertificate;

public class ClusterServer {

    static final boolean SSL = System.getProperty("ssl") != null;
    static final int PORT = Integer.parseInt(System.getProperty("port", SSL ? "8992" : "8023"));
    private ZoneExtension zoneExtension;

    public ClusterServer(ZoneExtension zoneExtension){
        super();
        this.zoneExtension = zoneExtension;
    }

    public void init() throws Exception {
        // Configure SSL.
        final SslContext sslCtx;
        if (SSL) {
            SelfSignedCertificate ssc = new SelfSignedCertificate();
            sslCtx = SslContextBuilder.forServer(ssc.certificate(), ssc.privateKey()).build();
        } else {
            sslCtx = null;
        }

        EventLoopGroup bossGroup = new NioEventLoopGroup(1);
        EventLoopGroup workerGroup = new NioEventLoopGroup();
        try {
            ServerBootstrap b = new ServerBootstrap();
            b.group(bossGroup, workerGroup)
                    .channel(NioServerSocketChannel.class)
                    .handler(new LoggingHandler(LogLevel.INFO))
                    .childHandler(new ClusterServerInitializer(sslCtx, zoneExtension));

            b.bind(PORT).sync().channel().closeFuture().sync();
        } finally {
            bossGroup.shutdownGracefully();
            workerGroup.shutdownGracefully();
        }
    }
}

import com.fhacktions.zone.ZoneExtension;
import io.netty.channel.ChannelInitializer;
import io.netty.channel.ChannelPipeline;
import io.netty.channel.socket.SocketChannel;
import io.netty.handler.codec.DelimiterBasedFrameDecoder;
import io.netty.handler.codec.Delimiters;
import io.netty.handler.codec.string.StringDecoder;
import io.netty.handler.codec.string.StringEncoder;
import io.netty.handler.ssl.SslContext;

public class ClusterServerInitializer extends ChannelInitializer<SocketChannel> {

      private static final StringDecoder DECODER = new StringDecoder();
      private static final StringEncoder ENCODER = new StringEncoder();

//      private static final ClusterServerHandler SERVER_HANDLER = new ClusterServerHandler(zoneExtension);
      private ClusterServerHandler SERVER_HANDLER;

      private final SslContext sslCtx;

      public ClusterServerInitializer(SslContext sslCtx, ZoneExtension zoneExtension) {
          this.sslCtx = sslCtx;
          SERVER_HANDLER = new ClusterServerHandler(zoneExtension);
      }

      @Override
      public void initChannel(SocketChannel ch) throws Exception {
          ChannelPipeline pipeline = ch.pipeline();

          if (sslCtx != null) {
              pipeline.addLast(sslCtx.newHandler(ch.alloc()));
          }

          // Add the text line codec combination first,
          pipeline.addLast(new DelimiterBasedFrameDecoder(8192, Delimiters.lineDelimiter()));
          // the encoder and decoder are static as these are sharable
          pipeline.addLast(DECODER);
          pipeline.addLast(ENCODER);

          // and then business logic.
          pipeline.addLast(SERVER_HANDLER);
      }
}

import com.fhacktions.zone.ZoneExtension;
import io.netty.channel.ChannelFuture;
import io.netty.channel.ChannelFutureListener;
import io.netty.channel.ChannelHandler.Sharable;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.SimpleChannelInboundHandler;

import java.net.InetAddress;
import java.util.Date;

/**
   * Handles a server-side channel.
   */
  @Sharable
  public class ClusterServerHandler extends SimpleChannelInboundHandler<String> {

      private ZoneExtension zoneExtension;
      public ClusterServerHandler(ZoneExtension zoneExtension){
          super();
          this.zoneExtension = zoneExtension;
      }

      @Override
      public void channelActive(ChannelHandlerContext ctx) throws Exception {
          // Send greeting for a new connection.
          ctx.write("Welcome to " + InetAddress.getLocalHost().getHostName() + "!\r\n");
          ctx.write("It is " + new Date() + " now.\r\n");
          ctx.write("We have " + zoneExtension.getParentZone().getUserCount() + " users in our server.\r\n");
          ctx.flush();
      }

      @Override
      public void channelRead0(ChannelHandlerContext ctx, String request) throws Exception {
          // Generate and write a response.
          String response;
          boolean close = false;
          if (request.isEmpty()) {
              response = "Please type something.\r\n";
          } else if ("bye".equals(request.toLowerCase())) {
              response = "Have a good day!\r\n";
              close = true;
          } else {
              response = "Did you say '" + request + "'?\r\n";
          }

          // We do not need to write a ChannelBuffer here.
          // We know the encoder inserted at ClusterPipelineFactory will do the conversion.
          ChannelFuture future = ctx.write(response);

          // Close the connection after sending 'Have a good day!'
          // if the client has sent 'bye'.
          if (close) {
              future.addListener(ChannelFutureListener.CLOSE);
          }
      }

      @Override
      public void channelReadComplete(ChannelHandlerContext ctx) {
          ctx.flush();
      }

      @Override
      public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) {
          cause.printStackTrace();
          ctx.close();
      }
}


Client (3 classes)

Code: Select all

import io.netty.bootstrap.Bootstrap;
import io.netty.channel.Channel;
import io.netty.channel.ChannelFuture;
import io.netty.channel.EventLoopGroup;
import io.netty.channel.nio.NioEventLoopGroup;
import io.netty.channel.socket.nio.NioSocketChannel;
import io.netty.handler.ssl.SslContext;
import io.netty.handler.ssl.SslContextBuilder;
import io.netty.handler.ssl.util.InsecureTrustManagerFactory;

import java.io.BufferedReader;
import java.io.InputStreamReader;

  /**
   * Simplistic telnet client.
   */
  public final class ClusterClient {

      static final boolean SSL = System.getProperty("ssl") != null;
      static final String HOST = System.getProperty("host", "192.168.1.163");
      static final int PORT = Integer.parseInt(System.getProperty("port", SSL? "8992" : "8023"));

      public static void main(String[] args) throws Exception {

          // Configure SSL.
          final SslContext sslCtx;
          if (SSL) {
              sslCtx = SslContextBuilder.forClient()
                  .trustManager(InsecureTrustManagerFactory.INSTANCE).build();
          } else {
              sslCtx = null;
          }

          EventLoopGroup group = new NioEventLoopGroup();
          try {
              Bootstrap b = new Bootstrap();
              b.group(group)
               .channel(NioSocketChannel.class)
               .handler(new ClusterClientInitializer(sslCtx));

              // Start the connection attempt.
              Channel ch = b.connect(HOST, PORT).sync().channel();

              // Read commands from the stdin.
              ChannelFuture lastWriteFuture = null;
              BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
              for (;;) {
                  String line = in.readLine();
                  if (line == null) {
                      break;
                  }

                  // Sends the received line to the server.
                  lastWriteFuture = ch.writeAndFlush(line + "\r\n");

                  // If user typed the 'bye' command, wait until the server closes
                  // the connection.
                  if ("bye".equals(line.toLowerCase())) {
                      ch.closeFuture().sync();
                      break;
                  }
              }

              // Wait until all messages are flushed before closing the channel.
              if (lastWriteFuture != null) {
                  lastWriteFuture.sync();
              }
          } finally {
              group.shutdownGracefully();
          }
      }
}

import io.netty.channel.ChannelInitializer;
import io.netty.channel.ChannelPipeline;
import io.netty.channel.socket.SocketChannel;
import io.netty.handler.codec.DelimiterBasedFrameDecoder;
import io.netty.handler.codec.Delimiters;
import io.netty.handler.codec.string.StringDecoder;
import io.netty.handler.codec.string.StringEncoder;
import io.netty.handler.ssl.SslContext;

  /**
   * Creates a newly configured {@link ChannelPipeline} for a new channel.
   */
  public class ClusterClientInitializer extends ChannelInitializer<SocketChannel> {

      private static final StringDecoder DECODER = new StringDecoder();
      private static final StringEncoder ENCODER = new StringEncoder();

      private static final ClusterClientHandler CLIENT_HANDLER = new ClusterClientHandler();

      private final SslContext sslCtx;

      public ClusterClientInitializer(SslContext sslCtx) {
          this.sslCtx = sslCtx;
      }

      @Override
      public void initChannel(SocketChannel ch) {
          ChannelPipeline pipeline = ch.pipeline();

          if (sslCtx != null) {
              pipeline.addLast(sslCtx.newHandler(ch.alloc(), ClusterClient.HOST, ClusterClient.PORT));
          }

          // Add the text line codec combination first,
          pipeline.addLast(new DelimiterBasedFrameDecoder(8192, Delimiters.lineDelimiter()));
          pipeline.addLast(DECODER);
          pipeline.addLast(ENCODER);

          // and then business logic.
          pipeline.addLast(CLIENT_HANDLER);
      }
}

import io.netty.channel.ChannelHandler.Sharable;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.SimpleChannelInboundHandler;

  /**
   * Handles a client-side channel.
   */
  @Sharable
  public class ClusterClientHandler extends SimpleChannelInboundHandler<String> {

      @Override
      protected void channelRead0(ChannelHandlerContext ctx, String msg) throws Exception {
          System.err.println(msg);
      }

      @Override
      public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) {
          cause.printStackTrace();
          ctx.close();
      }
}
We made an awesome GPS - MOBA.
Try it out here: Get Fhacktions
User avatar
Lapo
Site Admin
Posts: 22999
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Do I have to ditch Netty?

Postby Lapo » 16 Mar 2018, 08:09

gabrielvpy wrote:It works as espected, I connect from the client and I get the responses. But genereted an unexpexted problem. SFS2X won't autoload my jar if I update mi zone extension jar. What could be causing that?

Does it throw any errors?
If so paste here the stack trace.

Thanks
Lapo

--

gotoAndPlay()

...addicted to flash games
User avatar
gabrielvpy
Posts: 69
Joined: 23 Jul 2015, 20:18

Re: Do I have to ditch Netty?

Postby gabrielvpy » 16 Mar 2018, 11:28

Lapo wrote:
gabrielvpy wrote:It works as espected, I connect from the client and I get the responses. But genereted an unexpexted problem. SFS2X won't autoload my jar if I update mi zone extension jar. What could be causing that?

Does it throw any errors?
If so paste here the stack trace.

Thanks

It does not.
We made an awesome GPS - MOBA.
Try it out here: Get Fhacktions
User avatar
Lapo
Site Admin
Posts: 22999
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Do I have to ditch Netty?

Postby Lapo » 16 Mar 2018, 14:56

We need more details to be able to help.
So what happens when you reload the Extension?
Normally you see specific logs telling you that the new extension was started and the old one was removed from memory.

Do you see that?
If you trace a log messages in the init() does it show on reload?

thanks
Lapo

--

gotoAndPlay()

...addicted to flash games
User avatar
gabrielvpy
Posts: 69
Joined: 23 Jul 2015, 20:18

Re: Do I have to ditch Netty?

Postby gabrielvpy » 16 Mar 2018, 17:23

Lapo wrote:We need more details to be able to help.
So what happens when you reload the Extension?
Normally you see specific logs telling you that the new extension was started and the old one was removed from memory.

Do you see that?
If you trace a log messages in the init() does it show on reload?

thanks

Ok, so I was testing only the telnet server but turns out if my zone extension initializes the telnet server SFS2X doesn't work at all.

here is the output WITHOUT the telnet server

Code: Select all

14:21:25,150 INFO  [main] v2.SmartFoxServer     - Boot sequence starts...
14:21:25,438 INFO  [main] core.SFSEventManager     - AnonymousService-1 initialized
14:21:25,462 INFO  [main] impl.DefaultFileReplicator     - Using "/tmp/vfs_cache" as temporary files store.
14:21:25,506 INFO  [main] v2.SmartFoxServer     - License loaded:

==========================================
LICENSE DETAILS
------------------------------------------
Type            : Community Edition
Max users       : 100
==========================================

14:21:25,506 INFO  [main] managers.SFSBannedUserStorage     - BanUserStorage initialized
14:21:25,512 INFO  [main] managers.SFSBannedUserManager     - BanUser data loaded: 0 records.
14:21:25,516 INFO  [main] v2.SmartFoxServer     - Protocol Type is: BINARY
14:21:25,518 INFO  [main] config.DefaultConfigLoader     - Loading: zones/ProyectoUno.zone.xml
14:21:25,539 INFO  [main] managers.SFSZoneManager     -

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
 >> Zone: ProyectoUno
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

14:21:25,623 WARN  [main] managers.SFSZoneManager     - RoomSetting literal not found:
14:21:25,627 INFO  [main] managers.SFSRoomManager     - Room created: { Zone: ProyectoUno }, [ Room: Menu, Id: 0, Group: default, isGame: false ], type = SFSRoom
14:21:25,631 INFO  [main] Extensions     - {MenuExtension}: Menu Extension -- started
14:21:25,645 INFO  [main] Extensions     - {ZoneExtension}: Start oooooooooooo
14:21:25,659 INFO  [main] Extensions     - {ZoneExtension}: Client platform/version: ios/0.7.0/{0.8.5,0.8.6,0.8.7,0.8.8,0.8.9,0.9.0,0.9.1,0.9.2,0.9.3,0.9.4,0.9.5,0.9.6}
14:21:25,659 INFO  [main] Extensions     - {ZoneExtension}: Client platform/version: android/0.6.9.1/{0.8.5,0.8.6,0.8.7,0.8.8,0.8.9,0.9.0,0.9.1,0.9.2,0.9.3,0.9.4,0.9.5,0.9.6}
14:21:25,662 INFO  [main] managers.SFSRoomManager     - Room created: { Zone: --=={{{ AdminZone }}}==-- }, [ Room: AdminRoom, Id: 1, Group: default, isGame: false ], type = SFSRoom
14:21:25,689 INFO  [main] core.AdminToolService     - AdminTool Service started
14:21:25,760 INFO  [SFSWorker:Sys:1] v2.SmartFoxServer     - Listening Sockets: { 0.0.0.0:9933, (Tcp) } { 127.0.0.1:9933, (Udp) }
14:21:25,761 INFO  [SFSWorker:Sys:1] v2.SmartFoxServer     -
 _____ _____ _____    ___ __ __
|   __|   __|   __|  |_  |  |  |
|__   |   __|__   |  |  _|-   -|
|_____|__|  |_____|  |___|__|__|
 _____ _____ _____ ____  __ __
| __  |   __|  _  |    \|  |  |
|    -|   __|     |  |  |_   _|
|__|__|_____|__|__|____/  |_|
[ 2.13.0 ]

14:21:25,761 INFO  [SFSWorker:Sys:1] v2.SmartFoxServer     - SmartFoxServer 2X (2.13.0) READY!
14:21:27,208 INFO  [main] v3.SessionFilter     - BlueBox-2X Service (3.1.0) READY.


here is the output WITH the telnet server (server doesn't completely start)

Code: Select all

14:22:07,891 INFO  [main] v2.SmartFoxServer     - Boot sequence starts...
14:22:08,171 INFO  [main] core.SFSEventManager     - AnonymousService-1 initialized
14:22:08,188 INFO  [main] impl.DefaultFileReplicator     - Using "/tmp/vfs_cache" as temporary files store.
14:22:08,228 INFO  [main] v2.SmartFoxServer     - License loaded:

==========================================
LICENSE DETAILS
------------------------------------------
Type            : Community Edition
Max users       : 100
==========================================

14:22:08,229 INFO  [main] managers.SFSBannedUserStorage     - BanUserStorage initialized
14:22:08,235 INFO  [main] managers.SFSBannedUserManager     - BanUser data loaded: 0 records.
14:22:08,239 INFO  [main] v2.SmartFoxServer     - Protocol Type is: BINARY
14:22:08,241 INFO  [main] config.DefaultConfigLoader     - Loading: zones/ProyectoUno.zone.xml
14:22:08,271 INFO  [main] managers.SFSZoneManager     -

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
 >> Zone: ProyectoUno
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

14:22:08,357 WARN  [main] managers.SFSZoneManager     - RoomSetting literal not found:
14:22:08,361 INFO  [main] managers.SFSRoomManager     - Room created: { Zone: ProyectoUno }, [ Room: Menu, Id: 0, Group: default, isGame: false ], type = SFSRoom
14:22:08,366 INFO  [main] Extensions     - {MenuExtension}: Menu Extension -- started
14:22:08,381 INFO  [main] Extensions     - {ZoneExtension}: Start oooooooooooo
14:22:08,395 INFO  [main] Extensions     - {ZoneExtension}: Client platform/version: ios/0.7.0/{0.8.5,0.8.6,0.8.7,0.8.8,0.8.9,0.9.0,0.9.1,0.9.2,0.9.3,0.9.4,0.9.5,0.9.6}
14:22:08,396 INFO  [main] Extensions     - {ZoneExtension}: Client platform/version: android/0.6.9.1/{0.8.5,0.8.6,0.8.7,0.8.8,0.8.9,0.9.0,0.9.1,0.9.2,0.9.3,0.9.4,0.9.5,0.9.6}
14:22:08,546 INFO  [nioEventLoopGroup-2-1] logging.LoggingHandler     - [id: 0xbbabb640] REGISTERED
14:22:08,548 INFO  [nioEventLoopGroup-2-1] logging.LoggingHandler     - [id: 0xbbabb640] BIND: 0.0.0.0/0.0.0.0:8023
14:22:08,552 INFO  [nioEventLoopGroup-2-1] logging.LoggingHandler     - [id: 0xbbabb640, L:/0:0:0:0:0:0:0:0:8023] ACTIVE


This is what happens if I'm logged in the server WHITOUT telnet server but I copy a new jar WITH the telnet server. It reloads the zone but fail to perform whatever the client requests.

Code: Select all

16 Mar 2018 | 14:22:02,662 | INFO  | Thread-4 | entities.managers.SFSExtensionManager |     | Reloading extension: { Ext: ZoneExtension, Type: JAVA, Lev: ZONE, { Zone: ProyectoUno }, {} }
16 Mar 2018 | 14:22:02,663 | INFO  | Thread-4 | Extensions |     | {ZoneExtension}: Start oooooooooooo
16 Mar 2018 | 14:22:02,673 | INFO  | Thread-4 | Extensions |     | {ZoneExtension}: Client platform/version: ios/0.7.0/{0.8.5,0.8.6,0.8.7,0.8.8,0.8.9,0.9.0,0.9.1,0.9.2,0.9.3,0.9.4,0.9.5,0.9.6}
16 Mar 2018 | 14:22:02,674 | INFO  | Thread-4 | Extensions |     | {ZoneExtension}: Client platform/version: android/0.6.9.1/{0.8.5,0.8.6,0.8.7,0.8.8,0.8.9,0.9.0,0.9.1,0.9.2,0.9.3,0.9.4,0.9.5,0.9.6}
16 Mar 2018 | 14:22:03,054 | INFO  | SocketReader | bitswarm.sessions.DefaultSessionManager |     | Session created: { Id: 1, Type: DEFAULT, Logged: No, IP: 181.40.82.30:57802 } on Server port: 9933 <---> 57802
16 Mar 2018 | 14:22:03,362 | INFO  | SFSWorker:Ext:4 | v2.api.SFSApi |     | User login: { Zone: ProyectoUno }, ( User Name: Sigfrancis-A1, Id: 0, Priv: 1, Sess: 181.40.82.30:57802 ) , Type: Android:0.9.6
16 Mar 2018 | 14:22:03,404 | INFO  | SFSWorker:Ext:4 | v2.scala.DefLI |     | User already logged in. Disconnecting previous instance : ( User Name: Sigfrancis-A1, Id: 0, Priv: 1, Sess: 181.40.82.30:57802 )
16 Mar 2018 | 14:22:03,404 | INFO  | SFSWorker:Ext:4 | bitswarm.sessions.DefaultSessionManager |     | Session removed: { Id: 1, Type: DEFAULT, Logged: Yes, IP: 181.40.82.30:57802 }
16 Mar 2018 | 14:22:03,406 | INFO  | SFSWorker:Ext:4 | v2.api.SFSApi |     | User disconnected: { Zone: ProyectoUno }, ( User Name: Sigfrancis-A1, Id: 0, Priv: 1, Sess: 181.40.82.30:57802 ) , SessionLen: 44, Type: Android:0.9.6
16 Mar 2018 | 14:22:03,801 | INFO  | SFSWorker:Ext:1 | v2.api.SFSApi |     | Room joined: [ Room: Menu, Id: 0, Group: default, isGame: false ], { Zone: ProyectoUno }, ( User Name: Sigfrancis-A1, Id: 0, Priv: 1, Sess: 181.40.82.30:57802 ) , asSpect: false
16 Mar 2018 | 14:22:03,802 | WARN  | SFSWorker:Ext:1 | v2.core.SFSEventManager |     | java.lang.NoClassDefFoundError:
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
Exception: java.lang.NoClassDefFoundError
Message: com/fhacktions/zone/Runnables/UserUpdate
Description: Error handling event: { USER_JOIN_ZONE, Params: [ZONE, USER] } Listener: com.smartfoxserver.v2.entities.managers.SFSExtensionManager@2d8f1f04
+--- --- ---+
Stack Trace:
+--- --- ---+
com.fhacktions.zone.handlers.ZoneJoinEventHandler.handleServerEvent(ZoneJoinEventHandler.java:132)
com.smartfoxserver.v2.extensions.SFSExtension.handleServerEvent(SFSExtension.java:259)
com.smartfoxserver.v2.entities.managers.SFSExtensionManager.dispatchEvent(SFSExtensionManager.java:768)
com.smartfoxserver.v2.entities.managers.SFSExtensionManager.dispatchZoneLevelEvent(SFSExtensionManager.java:689)
com.smartfoxserver.v2.entities.managers.SFSExtensionManager.handleServerEvent(SFSExtensionManager.java:890)
com.smartfoxserver.v2.core.SFSEventManager$SFSEventRunner.run(SFSEventManager.java:65)
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
java.lang.Thread.run(Thread.java:745)
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

16 Mar 2018 | 14:22:04,425 | INFO  | SocketReader | bitswarm.sessions.DefaultSessionManager |     | Session created: { Id: 2, Type: DEFAULT, Logged: No, IP: 181.40.82.30:46945 } on Server port: 9933 <---> 46945
16 Mar 2018 | 14:22:04,437 | WARN  | SFSWorker:Sys:1 | controllers.v290.SystemReqController |     | com.smartfoxserver.bitswarm.exceptions.SessionReconnectionException: Session Reconnection failure. The passed Session is not managed by the ReconnectionManager: java.nio.channels.SocketChannel[connected local=/192.168.1.111:9933 remote=/181.40.82.30:46945]
   com.smartfoxserver.bitswarm.sessions.DefaultReconnectionManager.reconnectSession(DefaultReconnectionManager.java:146)
   com.smartfoxserver.bitswarm.sessions.DefaultSessionManager.reconnectSession(DefaultSessionManager.java:383)
   com.smartfoxserver.v2.controllers.system.Handshake.execute(Handshake.java:68)
   com.smartfoxserver.v2.controllers.v290.SystemReqController.processRequest(SystemReqController.java:172)
   com.smartfoxserver.v2.controllers.v290.SystemReqController.enqueueRequest(SystemReqController.java:127)
   com.smartfoxserver.bitswarm.io.protocols.AbstractProtocolCodec.dispatchRequestToController(AbstractProtocolCodec.java:39)
   com.smartfoxserver.v2.protocol.SFSProtocolCodec.dispatchRequest(SFSProtocolCodec.java:133)
   com.smartfoxserver.v2.protocol.SFSProtocolCodec.onPacketRead(SFSProtocolCodec.java:90)
   com.smartfoxserver.v2.protocol.binary.BinaryIoHandler$1.run(BinaryIoHandler.java:477)
   java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
   java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
   java.lang.Thread.run(Thread.java:745)

16 Mar 2018 | 14:22:04,456 | INFO  | SocketReader | bitswarm.sessions.DefaultSessionManager |     | Session removed: { Id: 2, Type: DEFAULT, Logged: No, IP: 181.40.82.30:46945 }
16 Mar 2018 | 14:22:05,406 | WARN  | pool-1-thread-4 | v2.api.SFSApi |     | Login failed: Sigfrancis-A1 , session is already expired!
We made an awesome GPS - MOBA.
Try it out here: Get Fhacktions
User avatar
Lapo
Site Admin
Posts: 22999
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Do I have to ditch Netty?

Postby Lapo » 18 Mar 2018, 18:26

Hi,
I have no idea what might be happening.
It seems weird that Netty causes so many issues. Until version 3.x there was no problem integrating it with SFS2X and typically I would not expect any issues in that regards, as I can't think of any specific sources of "interference" between the two.

The fact that SFS2X doesn't complete the boot seems to indicate that the Netty code is not releasing the main thread.
In the "Discard Server" example they use this line:
f.channel().closeFuture().sync();

Maybe that's the cause of your issues too, as you don't want to pause the main thread or SFS2X won't complete the boot process.

cheers
Lapo

--

gotoAndPlay()

...addicted to flash games
User avatar
gabrielvpy
Posts: 69
Joined: 23 Jul 2015, 20:18

Re: Do I have to ditch Netty?

Postby gabrielvpy » 19 Mar 2018, 18:22

Ok, so I've changed my zone extension in order to have an independent thread do the work and not lock any main thread.

Code: Select all

//Cluster server up
        ZoneExtension estaZona = this;
        clusterTask = SmartFoxServer.getInstance().getTaskScheduler().schedule(
                new TimerTask() {
                    @Override
                    public void run() {
                        try {
                            ClusterServer clusterServer = new ClusterServer(estaZona);
                            clusterServer.init();
                        } catch (Exception e) {
                            e.printStackTrace();
                        }
                    }
                }, 0, TimeUnit.SECONDS);


And when I make a change in my extension and redeploy it this is what happens.

Code: Select all

15:28:30,892 INFO  [main] v2.SmartFoxServer     - Boot sequence starts...
15:28:34,697 INFO  [main] core.SFSEventManager     - AnonymousService-1 initialized
15:28:34,819 INFO  [main] impl.DefaultFileReplicator     - Using "C:\Users\Gabriel\AppData\Local\Temp\vfs_cache" as temporary files store.
15:28:35,284 INFO  [main] v2.SmartFoxServer     - License loaded:

==========================================
LICENSE DETAILS
------------------------------------------
Type            : Community Edition
Max users       : 100
==========================================

15:28:35,285 INFO  [main] managers.SFSBannedUserStorage     - BanUserStorage initialized
15:28:35,383 INFO  [main] managers.SFSBannedUserManager     - BanUser data loaded: 0 records.
15:28:35,423 INFO  [main] v2.SmartFoxServer     - Protocol Type is: BINARY
15:28:35,475 INFO  [main] config.DefaultConfigLoader     - Loading: zones\ProyectoUno.zone.xml
15:28:35,593 INFO  [main] managers.SFSZoneManager     -

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
 >> Zone: ProyectoUno
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

15:28:37,352 INFO  [main] managers.SFSRoomManager     - Room created: { Zone: ProyectoUno }, [ Room: The Lobby, Id: 0, Group: default, isGame: false ]
15:28:37,353 WARN  [main] managers.SFSZoneManager     - RoomSetting literal not found:
15:28:37,354 INFO  [main] managers.SFSRoomManager     - Room created: { Zone: ProyectoUno }, [ Room: Menu, Id: 1, Group: default, isGame: false ]
15:28:37,466 INFO  [main] Extensions     - {MenuExtension}: Menu Extension -- started
15:28:37,578 INFO  [main] Extensions     - {ZoneExtension}: Start 111111111111
15:28:38,018 INFO  [main] Extensions     - {ZoneExtension}: Client platform/version: android/0.6.9.1/{0.8.5,0.8.6,0.8.7,0.8.8,0.8.9}
15:28:38,019 INFO  [main] Extensions     - {ZoneExtension}: Client platform/version: ios/0.7.0/{0.8.5,0.8.6,0.8.7,0.8.8,0.8.9}
15:28:38,110 INFO  [main] managers.SFSRoomManager     - Room created: { Zone: --=={{{ AdminZone }}}==-- }, [ Room: AdminRoom, Id: 2, Group: default, isGame: false ]
15:28:38,120 INFO  [main] core.AdminToolService     - AdminTool Service started
15:28:39,565 INFO  [SFSWorker:Sys:1] v2.SmartFoxServer     - Listening Sockets: { 0.0.0.0:9933, (Tcp) } { 127.0.0.1:9933, (Udp) }
15:28:39,577 INFO  [SFSWorker:Sys:1] v2.SmartFoxServer     -
 _____ _____ _____    ___ __ __
|   __|   __|   __|  |_  |  |  |
|__   |   __|__   |  |  _|-   -|
|_____|__|  |_____|  |___|__|__|
 _____ _____ _____ ____  __ __
| __  |   __|  _  |    \|  |  |
|    -|   __|     |  |  |_   _|
|__|__|_____|__|__|____/  |_|
[ 2.11.1 ]

15:28:39,578 INFO  [SFSWorker:Sys:1] v2.SmartFoxServer     - SmartFoxServer 2X (2.11.1) READY!
15:28:44,924 INFO  [nioEventLoopGroup-2-1] logging.LoggingHandler     - [id: 0x2fa9de3b] REGISTERED
15:28:44,982 INFO  [nioEventLoopGroup-2-1] logging.LoggingHandler     - [id: 0x2fa9de3b] BIND: 0.0.0.0/0.0.0.0:8023
15:28:45,011 INFO  [nioEventLoopGroup-2-1] logging.LoggingHandler     - [id: 0x2fa9de3b, L:/0:0:0:0:0:0:0:0:8023] ACTIVE
15:28:49,487 INFO  [main] v3.SessionFilter     - BlueBox-2X Service (3.0.2) READY.

###############REDEPLOY STARTS HERE

15:29:08,966 INFO  [nioEventLoopGroup-2-1] logging.LoggingHandler     - [id: 0x2fa9de3b, L:/0:0:0:0:0:0:0:0:8023] READ: [id: 0x5e7eca00, L:/192.168.1.163:8023 - R:/192.168.1.163:63031]
15:29:08,968 INFO  [nioEventLoopGroup-2-1] logging.LoggingHandler     - [id: 0x2fa9de3b, L:/0:0:0:0:0:0:0:0:8023] READ COMPLETE
15:29:57,485 INFO  [Thread-4] managers.SFSExtensionManager     - Reloading extension: { Ext: ZoneExtension, Type: JAVA, Lev: ZONE, { Zone: ProyectoUno }, {} }
15:29:57,515 INFO  [Thread-4] Extensions     - {ZoneExtension}: Start 22222222222
15:29:57,533 INFO  [Thread-4] Extensions     - {ZoneExtension}: Client platform/version: android/0.6.9.1/{0.8.5,0.8.6,0.8.7,0.8.8,0.8.9}
15:29:57,534 INFO  [Thread-4] Extensions     - {ZoneExtension}: Client platform/version: ios/0.7.0/{0.8.5,0.8.6,0.8.7,0.8.8,0.8.9}
15:29:57,538 INFO  [Thread-4] Extensions     - {ZoneExtension}: Stopped
15:29:57,553 INFO  [nioEventLoopGroup-4-1] logging.LoggingHandler     - [id: 0x48426d97] REGISTERED
15:29:57,554 INFO  [nioEventLoopGroup-4-1] logging.LoggingHandler     - [id: 0x48426d97] BIND: 0.0.0.0/0.0.0.0:8023
15:29:57,578 INFO  [nioEventLoopGroup-4-1] logging.LoggingHandler     - [id: 0x48426d97] CLOSE
log4j:WARN No appenders could be found for logger (com.fhacktions.zone.ZoneExtension).15:29:57,582 INFO  [nioEventLoopGroup-4-1] logging.LoggingHandler     - [id: 0x48426d97] UNREGISTERED

log4j:WARN Please initialize the log4j system properly.
java.net.BindException: Address already in use: bind
        at sun.nio.ch.Net.bind0(Native Method)
        at sun.nio.ch.Net.bind(Net.java:433)
        at sun.nio.ch.Net.bind(Net.java:425)
        at sun.nio.ch.ServerSocketChannelImpl.bind(ServerSocketChannelImpl.java:223)
        at io.netty.channel.socket.nio.NioServerSocketChannel.doBind(NioServerSocketChannel.java:128)
        at io.netty.channel.AbstractChannel$AbstractUnsafe.bind(AbstractChannel.java:558)
        at io.netty.channel.DefaultChannelPipeline$HeadContext.bind(DefaultChannelPipeline.java:1338)
        at io.netty.channel.AbstractChannelHandlerContext.invokeBind(AbstractChannelHandlerContext.java:501)
        at io.netty.channel.AbstractChannelHandlerContext.bind(AbstractChannelHandlerContext.java:486)
        at io.netty.handler.logging.LoggingHandler.bind(LoggingHandler.java:191)
        at io.netty.channel.AbstractChannelHandlerContext.invokeBind(AbstractChannelHandlerContext.java:501)
        at io.netty.channel.AbstractChannelHandlerContext.bind(AbstractChannelHandlerContext.java:486)
        at io.netty.channel.DefaultChannelPipeline.bind(DefaultChannelPipeline.java:999)
        at io.netty.channel.AbstractChannel.bind(AbstractChannel.java:254)
        at io.netty.bootstrap.AbstractBootstrap$2.run(AbstractBootstrap.java:366)
        at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:163)
        at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:404)
        at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:463)
        at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:886)
        at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
        at java.lang.Thread.run(Thread.java:745)
We made an awesome GPS - MOBA.
Try it out here: Get Fhacktions
User avatar
Lapo
Site Admin
Posts: 22999
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Do I have to ditch Netty?

Postby Lapo » 20 Mar 2018, 08:21

Ok, so it looks like you're making progress.
You still have two errors. The main one is a bind exception meaning that you're attempting to bind a TCP port that is already used.
Just make sure to use a port that is not already in use.

The other error is related to the logging system: it looks like you're using the Logger classes directly instead of the trace() Extension method. The easier way is to use trace().
Otherwise you can register your own packages in SFS2X main logger config file, by editing the {SFS2X}/config/log4j.properties file.

Cheers
Lapo

--

gotoAndPlay()

...addicted to flash games
User avatar
gabrielvpy
Posts: 69
Joined: 23 Jul 2015, 20:18

Re: Do I have to ditch Netty?

Postby gabrielvpy » 20 Mar 2018, 11:28

Lapo wrote:Ok, so it looks like you're making progress.
You still have two errors. The main one is a bind exception meaning that you're attempting to bind a TCP port that is already used.
Just make sure to use a port that is not already in use.

I think the telnet server is not releasing its port and that's why I can't reload the extension.

Lapo wrote:The other error is related to the logging system: it looks like you're using the Logger classes directly instead of the trace() Extension method. The easier way is to use trace().
Otherwise you can register your own packages in SFS2X main logger config file, by editing the {SFS2X}/config/log4j.properties file.

Cheers

I do actually use separate loggers and they work fine. Here's an example. This is the first time that error happens.

Code: Select all

# ConquestLobbyExtensionAppender FileAppender
log4j.appender.ConquestLobbyExtensionAppender=org.apache.log4j.DailyRollingFileAppender
log4j.appender.ConquestLobbyExtensionAppender.layout=org.apache.log4j.PatternLayout
log4j.appender.ConquestLobbyExtensionAppender.File=logs/ConquestLobby/ConquestLobbyExtension.log
log4j.appender.ConquestLobbyExtensionAppender.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss.SSS} ; %-5p ; %t %m%n
log4j.appender.ConquestLobbyExtensionAppender.Encoding=UTF-8
log4j.appender.ConquestLobbyExtensionAppender.DatePattern='.'yyyy-MM-dd
log4j.category.com.fhacktions.lobby.conquest=INFO,ConquestLobbyExtensionAppender,consoleAppender

# nettyAppender FileAppender
log4j.appender.nettyAppender=org.apache.log4j.DailyRollingFileAppender
log4j.appender.nettyAppender.layout=org.apache.log4j.PatternLayout
log4j.appender.nettyAppender.File=logs/netty.log
log4j.appender.nettyAppender.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss.SSS} ; %-5p ; %t %m%n
log4j.appender.nettyAppender.Encoding=UTF-8
log4j.appender.nettyAppender.DatePattern='.'yyyy-MM-dd
log4j.category.io.netty=INFO,nettyAppender,consoleAppender
We made an awesome GPS - MOBA.
Try it out here: Get Fhacktions

Return to “SFS2X Questions”

Who is online

Users browsing this forum: Baidu [Spider] and 37 guests