aionnetwork / aion

Aion Network - Java Implementation
https://theoan.com/
MIT License
337 stars 112 forks source link

Socket connection failure with Cli port input #751

Closed beidouz closed 5 years ago

beidouz commented 5 years ago

Before filing a new issue, please provide the following information.

I'm running:

  • Which Aion version?: v0.3.2 - Ama Dablam

Your issue description goes here below. Try to include actual vs. expected behavior and steps to reproduce the issue.

Related to PR: https://github.com/aionnetwork/aion/pull/736

If start the kernel using ./aion.sh --port 140, it will pass the basic port validation but fails to open the socket using port 140. However,

  1. After passing the basic port check, port number 140 is already updated in the config.xml
  2. The kernel keeps running

Example:

18-12-11 18:09:41.381 INFO  GEN  [main]: loaded block <num=0, root=5fa1a018... l=32>
18-12-11 18:09:41.810 ERROR P2P  [main]: Failed to connect to Socket Address: 0.0.0.0:140, please check your ip and port configration!
java.net.SocketException: Permission denied
    at java.base/sun.nio.ch.Net.bind0(Native Method)
    at java.base/sun.nio.ch.Net.bind(Net.java:461)
    at java.base/sun.nio.ch.Net.bind(Net.java:453)
    at java.base/sun.nio.ch.ServerSocketChannelImpl.bind(ServerSocketChannelImpl.java:227)
    at java.base/sun.nio.ch.ServerSocketAdaptor.bind(ServerSocketAdaptor.java:80)
    at org.aion.p2p.impl1.P2pMgr.run(P2pMgr.java:196)
    at org.aion.zero.impl.AionHub.initializeHub(AionHub.java:205)
    at org.aion.zero.impl.AionHub.<init>(AionHub.java:125)
    at org.aion.zero.impl.blockchain.AionImpl.<init>(AionImpl.java:77)
    at org.aion.zero.impl.blockchain.AionImpl.<init>(AionImpl.java:55)
    at org.aion.zero.impl.blockchain.AionImpl$Holder.<clinit>(AionImpl.java:68)
    at org.aion.zero.impl.blockchain.AionImpl.inst(AionImpl.java:72)
    at org.aion.zero.impl.blockchain.AionFactory.create(AionFactory.java:34)
    at org.aion.Aion.main(Aion.java:223)
Exception in thread "p2p-in" java.lang.ClassCastException: class sun.nio.ch.ServerSocketChannelImpl cannot be cast to class java.nio.channels.SocketChannel (sun.nio.ch.ServerSocketChannelImpl and java.nio.channels.SocketChannel are in module java.base of loader 'bootstrap')
    at org.aion.p2p.impl1.tasks.TaskInbound.run(TaskInbound.java:138)
    at java.base/java.lang.Thread.run(Thread.java:834)
18-12-11 18:09:41.849 INFO  P2P  [p2p-ts]: 
======================================================================== p2p-status-802cc5 =========================================================================
temp[  6] inbound[  0] outbound[  0] active[  0]                                         s - seed node, td - total difficulty, # - block number, bv - binary version

          s               td          #                                                             hash              ip  port     conn              bv           ci
--------------------------------------------------------------------------------------------------------------------------------------------------------------------

18-12-11 18:09:41.850 INFO  GEN  [main]: <node-started endpoint=p2p://802cc506-5aba-4948-ba9e-517c8f4eef65@0.0.0.0:140>
18-12-11 18:09:41.854 INFO  CONS [main]: <sealing-disabled>
18-12-11 18:09:51.854 INFO  P2P  [p2p-ts]: 
======================================================================== p2p-status-802cc5 =========================================================================
temp[  6] inbound[  0] outbound[  5] active[  0]                                         s - seed node, td - total difficulty, # - block number, bv - binary version

          s               td          #                                                             hash              ip  port     conn              bv           ci
AionJayT commented 5 years ago

port 140 is a predefined port for EMFIS Data Service. Therefore it requires the admin privilege to overwrite the socket binding check. https://www.speedguide.net/port.php?port=140