question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Stream can not be received in a few minutes

See original GitHub issue

When the stream stops, no error is displayed. How can I improve the fault tolerance of my application?

example codes

// main.scala
import com.danielasfregola.twitter4s.entities.enums.Language
import com.danielasfregola.twitter4s.{TwitterStreamingClient}
import com.danielasfregola.twitter4s.entities.{Tweet}
object main {
  def main(args: Array[String]): Unit = {
    val streamingClient = TwitterStreamingClient()
    streamingClient.sampleStatuses(Seq(Language.Japanese)) {
      case tweet: Tweet => println(tweet.text)
      case other => println(other)
    }

    println("Pooling...")
    if (io.StdIn.readLine != null) {
      println("Shutdown")
      streamingClient.system.terminate()
    }
  }
}
// build.sbt

scalaVersion := "2.11.8"

resolvers += Resolver.sonatypeRepo("releases")

libraryDependencies ++= {
  val akkaVersion = "2.4.16"
  Seq(
    "com.typesafe.akka" %% "akka-actor" % akkaVersion,
    "com.danielasfregola" %% "twitter4s" % "4.0"
  )
}

fork in run := true
connectInput in run := true

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:9 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
DanielaSfregolacommented, Jan 6, 2017

Hi @kamijin-fanta, what about something like the following?

import akka.actor.ActorSystem
import com.danielasfregola.twitter4s.entities.enums.Language
import com.danielasfregola.twitter4s.entities.Tweet

import scala.concurrent.ExecutionContext.Implicits.global
import scala.util.{Failure, Success}

object Main extends App {
  
  implicit val system = ActorSystem()

  val streamingClient = TwitterStreamingClient()
  
  val result = streamingClient.sampleStatuses(Seq(Language.Japanese)) {
    case tweet: Tweet => println(tweet.text)
  }
  
  result.onComplete {
    case Success(_) => println("Success!")
    case Failure(ex) =>
      println(s"Failure :(  -- $ex")
      system.terminate()
  }
}

In general, the idea is that when a stream is completed a Future[Unit] will be returned. That future contains information on the connection of the stream, so in your case it will contain that the stream failed because of network issues.

0reactions
DanielaSfregolacommented, Apr 14, 2018

@aron-bordin could you please open a new issue? This issue has already been closed. Also, it would be great if you could include a representative fragment of your code.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Troubleshoot your YouTube live stream - Google Help
If you're logging into YouTube from a 3rd party streaming software and are not using a stream key. Contact the software's support team...
Read more >
Troubleshooting live events in Microsoft Stream (Classic)
In general, it can take a few minutes to get the setup going before you can start pushing your encoder. It is possible...
Read more >
How to Troubleshoot Live Streaming Issues with Broadcasting
If viewers can't see your live stream, they should be able to, but you should ensure your restrictions are configured properly. You may...
Read more >
Troubleshoot Live video | Meta Business Help Center
Avoid connectivity issues · If you have concerns about your internet quality, ensure your stream isn't configured to end in case of an...
Read more >
Can't Watch Because Twitch Stream Keeps Buffering? Fix It!
Buffering – you have to pause the video and give it a few minutes to load more before playing it. For live video...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found