LoginSignup
4
4

More than 5 years have passed since last update.

eventmachine not initialized: evma_connect_to_serverのエラー対処

Last updated at Posted at 2016-03-26

websocket-railsを使ってチャット機能を実装した時に掲題のエラーに悩まされましたので対処をメモ。

websocket-railsの参考にしたのは以下の記事様。
Railsで複数グループ対応のチャットアプリを作ってみた

上記記事ではスタンドアローンモードで実行していますが、今回はRedisに繋げてやっています。

【追記】
色々とやってみた結果をザクっとこちらにまとめました。ご参考ください。
websocket-railsの使い方

記事との相違

config/initializers/websocket_rails.rb
config.standalone = false
config.synchronize = true
config.redis_options = {:host => 'localhost', :port => '6379'}

evma_connect_to_serverと書いてあるのでEventMachineの接続先が設定されていないのかな?と当たりをつけて色々調べてみました。

そういやRedisと繋げてあるとこってあったっけ?と思ったら案の定なかったので以下のファイルを作成しました。

config/initialize/redis.rb
$redis = Redis.new(host: 'localhost', port: 6379, driver: :hiredis)

これでエラーは解消されました。

4
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
4