3

When i am trying to create a Typed Actor System using the object. It is normally creating the Actor System.

   implicit val askTimeout: Timeout = Timeout(5.seconds)
   ActorSystem[Nothing](MailSendActor.apply, "application")
 }

where MailSendACtor is my class which is calling the Actor.

But same thing when i am trying to do with play application i am getting error and it is not even creating teh ActorSystem.

java.net.BindException: [/127.0.0.1:2551] Address already in use
        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 sun.nio.ch.ServerSocketAdaptor.bind(ServerSocketAdaptor.java:74)
    at akka.io.TcpListener.liftedTree1$1(TcpListener.scala:60)
    at akka.io.TcpListener.<init>(TcpListener.scala:57)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
[error] p.a.h.DefaultHttpErrorHandler -
! @7g90lm1hi - Internal server error, for (GET) [/message] ->
play.api.http.HttpErrorHandlerExceptions$$anon$1: Execution exception[[RemoteTransportException: Failed to bind TCP to [127.0.0.1:2551] due to: Bind failed because of java.net.BindException: [/127.0.0.1:2551] Address already in use]]
    at play.api.http.HttpErrorHandlerExceptions$.throwableToUsefulException(HttpErrorHandler.scala:359)
    at play.api.http.DefaultHttpErrorHandler.onServerError(HttpErrorHandler.scala:261)
    at play.core.server.AkkaHttpServer$$anonfun$2.applyOrElse(AkkaHttpServer.scala:429)
    at play.core.server.AkkaHttpServer$$anonfun$2.applyOrElse(AkkaHttpServer.scala:421)
    at scala.concurrent.Future.$anonfun$recoverWith$1(Future.scala:413)
    at scala.concurrent.impl.Promise.$anonfun$transformWith$1(Promise.scala:37)
    at scala.concurrent.impl.CallbackRunnable.run(Promise.scala:60)
    at akka.dispatch.BatchingExecutor$AbstractBatch.processBatch(BatchingExecutor.scala:56)
    at akka.dispatch.BatchingExecutor$BlockableBatch.$anonfun$run$1(BatchingExecutor.scala:93)
    at scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:12)
Caused by: akka.remote.RemoteTransportException: Failed to bind TCP to [127.0.0.1:2551] due to: Bind failed because of java.net.BindException: [/127.0.0.1:2551] Address already in use
    at akka.remote.artery.tcp.ArteryTcpTransport$$anonfun$4.applyOrElse(ArteryTcpTransport.scala:275)
    at akka.remote.artery.tcp.ArteryTcpTransport$$anonfun$4.applyOrElse(ArteryTcpTransport.scala:269)
    at scala.concurrent.Future.$anonfun$recoverWith$1(Future.scala:413)
    at scala.concurrent.impl.Promise.$anonfun$transformWith$1(Promise.scala:37)
    at scala.concurrent.impl.CallbackRunnable.run(Promise.scala:60)
    at akka.dispatch.BatchingExecutor$AbstractBatch.processBatch(BatchingExecutor.scala:56)
    at akka.dispatch.BatchingExecutor$Batch.run(BatchingExecutor.scala:74)
    at akka.dispatch.internal.SameThreadExecutionContext$$anon$1.unbatchedExecute(SameThreadExecutionContext.scala:21)
    at akka.dispatch.BatchingExecutor.execute(BatchingExecutor.scala:123)
    at akka.dispatch.BatchingExecutor.execute$(BatchingExecutor.scala:117)
Caused by: akka.stream.impl.io.ConnectionSourceStage$$anon$1$$anon$2: Bind failed because of java.net.BindException: [/127.0.0.1:2551] Address already in use
Caused by: java.net.BindException: [/127.0.0.1:2551] Address already in use
    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 sun.nio.ch.ServerSocketAdaptor.bind(ServerSocketAdaptor.java:74)
    at akka.io.TcpListener.liftedTree1$1(TcpListener.scala:60)
    at akka.io.TcpListener.<init>(TcpListener.scala:57)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)

Is there any reason?

2 Answers2

1

I had a similar problem. In some cases, it can happen from having a parallel process using the same port number, but it is not always the case.

I did the following steps:

  1. First, I used netstat to view active processes to eliminate parallel processes - netstat -vanp tcp | grep <PORT_NUMBER> - In my case, I haven't found any parallel process.

  2. I have checked the localhost network traffic using Wireshark - filter based on tcp.port == <PORT_NUMBER> - and I have seen traffic-related only to my application

In my case, my conclusion was internal application problem with routes management, hope this helps.

Matan
  • 11
  • 1
0

Port 2551 are already used by some process, either stop any process running port number 2551 or change the port number of your Actor system and then start it.

Manjunath A
  • 81
  • 1
  • 2