(solved) spark streaming

D’apres le cours j’ai le notebook suivant, qui si je comprends bien ecoute sur le port 8887 du conteneur jupyter depuis lequel il est lancé…

from pyspark import SparkContext
from pyspark.streaming import StreamingContext
sc = SparkContext("local[2]", "WordCount")
sc.setLogLevel("ERROR")
ssc = StreamingContext(sc, 30)
lines = ssc.socketTextStream("localhost", 8887)
words = lines.flatMap(lambda line: line.lower().split(" "))
pairs = words.map(lambda word: (word, 1))
wordCounts = pairs.reduceByKey(lambda x, y: x + y)
wordCounts.pprint()
ssc.start()
ssc.awaitTermination()

je ne comprends pas trop l’utilisation proposée de netcat -lk 8887
pour moi ca devrait plutot etre echo message | nc localhost 8887 (ici connection refused)

En attendant, j’obtiens seulement une sortie vide… Une idée ?

Sinon j’ai ce log du notebook

 ERROR ReceiverTracker: Deregistered receiver for stream 0: Restarting receiver with delay 2000ms: Error connecting to localhost:8887 - java.net.ConnectException: Connection refused (Connection refused)

Bon finalement en lançant le netcat avant ca fonctionne comme prevu. J’avais juste mal compris