Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6010933
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T02:11:14+00:00 2026-05-23T02:11:14+00:00

I would like to use WebSockets in Scala and Play Framework. But I can’t

  • 0

I would like to use WebSockets in Scala and Play Framework. But I can’t get the Echo-server example to work.

What should I import for await() and disconnect()?

The error I get is Error raised is : not found: value await. I used the code below:

package controllers
import play._
import play.mvc._
import play.mvc.Http.WebSocketEvent
import play.mvc.Http.WebSocketFrame
import play.mvc.Http.WebSocketClose
import play.mvc.WebSocketController

object MySocket extends WebSocketController {
    def echo = {
        while(Http.Inbound.current().isOpen()) {

            val e : WebSocketEvent = 
        await(Http.Inbound.current().nextEvent()).asInstanceOf[WebSocketEvent]

            if(e.isInstanceOf[WebSocketFrame]) {
                val frame : WebSocketFrame = e.asInstanceOf[WebSocketFrame]

                if(!frame.isBinary) {
                    if(frame.textData.equals("quit")) {
                        Http.Outbound.current().send("Bye!");
                        disconnect();
                    } else {
                        Http.Outbound.current().send("Echo: " + frame.textData)
                    }
                }
            }
            if(e.isInstanceOf[WebSocketClose]) {
                Logger.info("Socket closed!")
            }
        }
    }
}

Here is the compilation error in the Terminal:

Compiling:
    /Users/jonas/play-1.2.2RC1/jonassite/app/MySocket.scala
/Users/jonas/play-1.2.2RC1/jonassite/app/MySocket.scala:14: not found: value await
            val e : WebSocketEvent = await(Http.Inbound.current().nextEvent()).asInstanceOf[WebSocketEvent]
                                     ^
/Users/jonas/play-1.2.2RC1/jonassite/app/MySocket.scala:20: not found: value disconnect
                        disconnect();
                        ^
two errors found
Compiling:
    /Users/jonas/play-1.2.2RC1/jonassite/app/MySocket.scala
/Users/jonas/play-1.2.2RC1/jonassite/app/MySocket.scala:14: not found: value await
            val e : WebSocketEvent = await(Http.Inbound.current().nextEvent()).asInstanceOf[WebSocketEvent]
                                     ^
/Users/jonas/play-1.2.2RC1/jonassite/app/MySocket.scala:20: not found: value disconnect
                        disconnect();
                        ^
two errors found
12:52:57,049 ERROR ~ 

@66lce6kp8
Internal Server Error (500) for request GET /handshake

Compilation error (In /app/MySocket.scala around line 14)
The file /app/MySocket.scala could not be compiled. Error raised is : not found: value await

play.exceptions.CompilationException: not found: value await
    at play.scalasupport.ScalaPlugin.compilationException(ScalaPlugin.scala:129)
    at play.scalasupport.ScalaPlugin.detectClassesChange(ScalaPlugin.scala:115)
    at play.plugins.PluginCollection.detectClassesChange(PluginCollection.java:358)
    at play.Play.detectChanges(Play.java:591)
    at play.Invoker$Invocation.init(Invoker.java:186)
    at Invocation.HTTP Request(Play!)
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T02:11:14+00:00Added an answer on May 23, 2026 at 2:11 am

    await() and disconnect() are methods available from the WebSocketController. However, these are currently only available in the Java version, and not Scala. See this post here on the play groups for more information.

    This should be available in the 1.0 release of the scala plugin, but for now if you want to use the aysnc features (await etc), then you will have to use Java, or take a look at the Java wrapper that one of the Play users have developed.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to use a TextBox for a password, but before the user
I would like to use the Tornado web server to connect to a HTTP
I would like to use ListBox1.loadfromfile method in .NET, but it doesn't seem to
I would like to use a component that exposes the datasource property, but instead
I would like to use longpolling, if the websocket isn't avaiable. But how to
Possibly really simple question, but I'm new to IronPython. I would like use IronPython
I would like to use WebSockets in my Windows Forms or WPF-application. Is there
I would like use .appendTo() on different elements determined by a function. For example,
I would like to use $a and $b variables in my anonimous binary functions
I would like to use the Roboto font in my Android application and make

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.