centOS5.5でWebSocketを使ってデータ通信する方法の調査

このQ&Aのポイント
  • HTML5のWebSocketを使用してクライアントとサーバのデータ通信方法について調査中です。
  • クライアント側では問題なく実装できましたが、サーバ側で問題が発生しています。
  • エラーメッセージによると、Native codeのコンパイルが失敗しているようです。サーバの環境や使用している言語のバージョンなどを確認し解決方法を探しています。
回答を見る
  • ベストアンサー

centOS5.5でwebsocket

何卒よろしくお願いします。 現在、HTML5のWebSocketを使ってやりとりをする方法を調査中なのですが、 クライアント側は比較的簡単でしたが、 サーバ側が全くうまくいきません。 現在 http://blog.justoneplanet.info/2011/03/23/%E3%81%95%E3%81%8F%E3%82%89%E3%81%AEvps%E3%82%9210%E5%88%86%E3%81%A7websocket%E3%82%B5%E3%83%BC%E3%83%90%E3%81%AB%E3%81%99%E3%82%8B/ を参考にいろいろと手を尽くしておりますが、 Native code compile failed!! On Windows, native extensions require Visual Studio and Python. On Unix, native extensions require Python, make and a C++ compiler. Start npm with --websocket:verbose to show compilation output (if any). websocket@1.0.7 ./node_modules/websocket というエラーが出てしまいます。 どなたかご教授頂けないでしょうか。 因みに、サーバは上記の通り CentOS release 5.5 (Final) Node.jsは0.6.16を入れました。 Python は2.4.3の用です PHPは5.1.6が入っております。 私の使える言語とてはPHPかCか位なのですが、 サンプル等がわかりやすければ勉強します。 どなたか何卒ご教授頂けますよう、宜しくお願いいたします。

  • tahke
  • お礼率94% (32/34)

質問者が選んだベストアンサー

  • ベストアンサー
  • Wr5
  • ベストアンサー率53% (2177/4070)
回答No.1

ドコの手順でエラーが発生しているのか…くらいは掲示された方が良いかと。 >というエラーが出てしまいます。 npm install websocket で…ですかね。 >Start npm with --websocket:verbose to show compilation output ってコトでオプション付けると…python 2.5以上が必要らしい。 「CentOS 5 python 2.5」で検索して… http://blog.wiredeffect.com/archives/691 2.5を導入してみてはどうですかね?

tahke
質問者

お礼

ありがとうございます! おっしゃるとおり npm install websocket で、でした。 察して頂いて、本当にありがとうございます。 試してみました! 下記の通りでました。 successful! とあるのでインストールできたような気がしております。 ありがとうございます。 Socketのテストしてみて、できたらベストアンサーにいたします! ありがとうございます! npm http GET https://registry.npmjs.org/websocket npm http 304 https://registry.npmjs.org/websocket > websocket@1.0.7 install /usr/bin/node_modules/websocket > node install.js [websocket v1.0.7] Attempting to compile native extensions. [websocket v1.0.7] Native extension compilation successful! websocket@1.0.7 ./node_modules/websocket

関連するQ&A

  • SyntaxError: Unexpected

    エラー:SyntaxError: Unexpected string nodeで実行しようとするとこのようなエラーが、 em-websocket.jsというファイルに、 以下の設定を記述しました。 require 'em-websocket' EventMachine.run { EventMachine::Websocket.start( :host => "0.0.0.0", :port => 6666, :secure => false) do |ws| begin ws.onmessage do |msg| p "Received:" p "->#{msg}" ws.send("alert(1);") end rescue Exception => e print_error "websocket error: #{e}" end end どこか間違っているのでしょうか? ご教示お願いします。

  • WebSocket通信

    サーバー側 require 'em-websocket' EventMachine.run { EventMachine::WebSocket.start( :host => "0.0.0.0", :port => 6666, :secure => false) do |ws| begin ws.onmessage do |msg| p "Received:" p "->#{msg}" ws.send("alert(1);") end rescue Exception => e print_error "WebSocket error: #{e}" end end } クライアント側のコード var socket = new WebSocket("ws://zeno.pb.online:8085/"); socket.onopen = function(){ console.log("Socket open."); socket.send("Server, send me commands."); } socket.onmessage = function(msg){ eval(msg.data); // msg is coming from the attacker server, so it's trusted console.log("Command received and executed."); } about:configで security.csp.enable network.websocket.allowInsecureFromHTTPS これらを無効にして、やってみたのですが、どうにもうまくいかず wss://〇〇〇〇〇〇:8085/ のサーバーへの接続を確立できませんでした。 と出るのですが原因が解りません。 宜しくお願いします。 因みにfirefox developer editionsを使っています。

  • WindowsとCentOSでのPHPの動作

    いつもお世話になっております。 Windows環境で開発したPHPアプリをCentOS環境に移行しようとしているのですが、 件名のとおり、PHPのrequireの動作がWindowsとCentOSで違うことから、 原因を調べております。お知恵を拝借したいと思います。 例えば、以下の構成で親プログラム(myApp.php)から子(myparts/main.php)を読み込もうとしています。 ドキュメントルート/test/myApp.php ドキュメントルート/parts/mypartsA/main.php ●myApp.php <?php echo ("##### myApp is starting now !!! </br>"); require_once('/parts/mypartsA/main.php'); ?> ●mypartsA/main.php <?php echo ("#### mypartsA is required </br>"); ?>And myApp.php and mypartsA/main.php are in following structure. 結果として、 ●Windowsでは、以下が表示されますが・・・ ##### myApp is starting now !!! #### mypartsA is required ●CentOSでは、以下のとおりエラーになります。 PHP Warning: require_once(/parts/mypartsA/main.php) [<a href='function.require-once'>function.require-once</a>]: failed to open stream: No such file or directory in /var/www/html/test/myApp.php on line 12 PHP Fatal error: require_once() [<a href='function.require'>function.require</a>]: Failed opening required (/parts/mypartsA/main.php’(include_path='.:/php/includes:/usr/share/pear:/usr/share/pear/PEAR:/var/www/html') in /var/www/html/test/myAPP.php on line 12 解決策として、以下のようにすればエラーが解消することは分かっているのですが・・・ require_once($_SERVER['DOCUMENT_ROOT']./parts/mypartsA/main.php); なるべく既存のアプリに手を入れたくないので、 何故Windowsではできて、何故CentOSではできないのかを知りたいと思います。 とりあえず、PHP.iniのinclude_pathを調べてみましたが、 表記方法の違いはあるものの、に意味的な違いが見つかりません。 ●Windowsでの設定 .;C:\PHP;C:\PHP\pear;C:\Apache2.2.22\htdocs ●CentOSでの設定 .:/php/includes:/usr/share/pear:/usr/share/pear/PEAR:/var/www/html この他何をポイントに調べていったらよいか教えていただければと思います。 よろしくお願いします。

    • ベストアンサー
    • PHP
  • Socket.ioがインストールできません

    こんにちは npmのモジュールでSocket.ioをインストールしようとしたのですがエラーがでてしまいます このコードの言っている意味は何でしょうか C:\Users\****\node_modules\socket.io\node_modules\socket.io-client\node_modules\ engine.io-client\node_modules\ws\node_modules\utf-8-validate>if not defined npm_ config_node_gyp (node "C:\Program Files (x86)\nodejs\node_modules\npm\bin\node-g yp-bin\\..\..\node_modules\node-gyp\bin\node-gyp.js" rebuild ) else (node rebu ild ) gyp ERR! configure error gyp ERR! stack Error: Can't find Python executable "python", you can set the PYT HON env variable. gyp ERR! stack at failNoPython (C:\Program Files (x86)\nodejs\node_modules\n pm\node_modules\node-gyp\lib\configure.js:114:14) gyp ERR! stack at C:\Program Files (x86)\nodejs\node_modules\npm\node_module s\node-gyp\lib\configure.js:69:11 gyp ERR! stack at FSReqWrap.oncomplete (evalmachine.<anonymous>:95:15) gyp ERR! System Windows_NT 6.3.9600 gyp ERR! command "node" "C:\\Program Files (x86)\\nodejs\\node_modules\\npm\\nod e_modules\\node-gyp\\bin\\node-gyp.js" "rebuild" gyp ERR! cwd C:\Users\***\node_modules\socket.io\node_modules\socket.io-client\ node_modules\engine.io-client\node_modules\ws\node_modules\utf-8-validate gyp ERR! node -v v0.12.7 gyp ERR! node-gyp -v v2.0.1 gyp ERR! not ok npm WARN optional dep failed, continuing utf-8-validate@1.1.0 なぜできないのでしょうか 宜しくお願いいたします

  • PHP4で動作していた以下のソースが、PHP5にバージョンアップしたら

    PHP4で動作していた以下のソースが、PHP5にバージョンアップしたらエラーが出るようになってしまいました。 どのように修正したらよいかご教授ください。 サーバーはロリポップです。 ■ソース <?php header('Content-Type: text/html; charset=SHIFT_JIS'); require("http://別ドメイン/estate.html"); ?> ■エラー Warning: require() [function.require]: URL file-access is disabled in the server configuration in /パス/ファイル名 on line 3 Warning: require(取り込みたいファイルのパス/estate.html) [function.require]: failed to open stream: no suitable wrapper could be found in /パス/ファイル名 on line 3 Fatal error: require() [function.require]: Failed opening required 取り込みたいファイルのパス/estate.html' (include_path='.:/usr/local/php5.2/php') in /パス/ファイル名 on line 3

    • ベストアンサー
    • PHP
  • パイソンとDjangoでHelloをCloud9で

    https://c9.io/ Cloud9とPythonとDjangoとTornado初心者です。 Cloud9で最初に、Helloを表示させて見たいのですが、 http://itfun.jp/2011/05/cloud9-idehello-world.html こちらで、Node.jsでのサンプルはあるのですが、 var http = require('http'); var server = http.createServer(  function (request, response) {   response.writeHead(200, {'Content-Type': 'text/plain'});   response.end('Hello World!!\n');  }).listen(process.env.C9_PORT); console.log('Server running'); このコードの意味も解らず。 PythonとDjangoとTornadoフレームワークに置き換えてサンプルソースをどなた様か書いて教えて頂ければ幸いです。

  • PHP requireでのURLパラメータ指定

    PHPにてアクセスカウンターを作っているのですが、呼び出したときのパラメータにて合計カウント数、本日のカウント数、昨日のカウント数のどれを表示するのか分けるプログラムを作成しました。 直接アドレスバーにて、 http://localhost/counter/count.php?mode=total とパラメータ指定したときにはきちんと表示出来るのですが、他のPHPファイルから require ("./count.php?mode=total"); で呼び出すと、 Warning: require(./count.php?mode=total) [function.require]: failed to open stream: No such file or directory in C:\xampp\htdocs\counter\index.php on line 7 Fatal error: require() [function.require]: Failed opening required './count.php?mode=total' (include_path='.;C:\xampp\php\PEAR') in C:\xampp\htdocs\counter\index.php on line 7 というエラーが出てしまいます。 色々調べたところ、相対パス指定のときにはパラメータ指定が出来ないという情報があったので、絶対パスで指定してみたのですが、やはり上手くいきません。 Warning: require() [function.require]: http:// wrapper is disabled in the server configuration by allow_url_include=0 in C:\xampp\htdocs\counter\index.php on line 7 Warning: require(http://localhost/counter/count.php?mode=total) [function.require]: failed to open stream: no suitable wrapper could be found in C:\xampp\htdocs\counter\index.php on line 7 Fatal error: require() [function.require]: Failed opening required 'http://localhost/counter/count.php?mode=total' (include_path='.;C:\xampp\php\PEAR') in C:\xampp\htdocs\counter\index.php on line 7 というようにエラーが出てしまいます。 どのようにすれば上手く表示できるでしょうか? 是非回答よろしくお願い致します。

    • ベストアンサー
    • PHP
  • さくらのレンタルサーバーでDB.php読み込み失敗

    下記の環境でPHPを書いています。 ・さくらのレンタルサーバ スタンダード ・PHP 5.2.13 ・php.iniファイルパス /home/******/www/php.ini その中で、require_once("DB.php");と記述をしているのですが、 その部分で下記のエラーが発生します。 Warning: require_once(DB.php) [function.require-once]: failed to open stream: No such file or directory in /home/xxx/www/class/db.class on line 6 Fatal error: require_once() [function.require]: Failed opening required 'DB.php' (include_path='.:/usr/local/php/5.2.13/lib/php') in /home/xxx/www/class/db.class on line 6 2ヶ月ほど前に作成した時は間違いなく正常に動作していたのですが・・・。 久しぶりにアクセスしたらこんなエラーが出ていて途方にくれています。 推測できる原因はありますでしょうか?

    • ベストアンサー
    • PHP
  • wordpressのURL変更について

    http://0000.com/wpをhttp://0000.comに変更をしようと思いました。 まず設定画面からサイトの名前をhttp://0000.com/wpからhttp://0000.comに変更し、 index.phpをFTPから抜き <?php /** * Front to the WordPress application. This file doesn't do anything, but loads * wp-blog-header.php which does and tells WordPress to load the theme. * * @package WordPress */ /** * Tells WordPress to load the WordPress theme and output it. * * @var bool */ define('WP_USE_THEMES', true); /** Loads the WordPress Environment and Template */ require('./wp-blog-header.php'); ?> の↓を変更。 /** Loads the WordPress Environment and Template */ require('./wordpress/wp-blog-header.php'); ?> その後一つ上の層にindex.phpをあげたのですがサイトにアクセスすると、 Warning: require(./wordpress/wp-blog-header.php) [function.require]: failed to open stream: No such file or directory in /home/sites/heteml/users113/0/1/f/01f-boy/web/pimp/index.php on line 17 Warning: require(./wordpress/wp-blog-header.php) [function.require]: failed to open stream: No such file or directory in /home/sites/heteml/users113/0/1/f/01f-boy/web/pimp/index.php on line 17 Fatal error: require() [function.require]: Failed opening required './wordpress/wp-blog-header.php' (include_path='.:/usr/local/php5/php') in /home/sites/heteml/users113/0/1/f/01f-boy/web/pimp/index.php on line 17 と出てきてサイトが表示されません 。 wp-blog-header.phpがなにかあるのかと思い開けると下記のコードが書いてありました。 <?php /** * Loads the WordPress environment and template. * * @package WordPress */ if ( !isset($wp_did_header) ) { $wp_did_header = true; require_once( dirname(__FILE__) . '/wp-load.php' ); wp(); require_once( ABSPATH . WPINC . '/template-loader.php' ); } ?> しかし自分はphpがよくわからないためどこを変更すればhttp://0000.comでサイトが見れるのかわかりません。 教えてください。

    • ベストアンサー
    • PHP
  • pearライブラリのインクルードについて

    PEARへのパスの通し方の方法を教えていただきたいと思います。 私はハッスルサーバーを使っており、以前に以下のサイトを参考にしてPEARをインストールしました。(PHPのバージョンは5.2です。) http://funweb.sblog.jp/blog/article/%E3%83%8F%E3%83%83%E3%82%B9%E3%83%AB%E3%82%B5%E3%83%BC%E3%83%90%E3%83%BC%E3%81%B8%E3%81%AEPEAR%E3%81%AE%E3%82%A4%E3%83%B3%E3%82%B9%E3%83%88%E3%83%BC%E3%83%AB その後、XML-RPCを使用したPHPプログラムを作成し、 以下の場所に配置しました。 <ドキュメントルート配下> ・pear(フォルダ)   ・bin(フォルダ)   ・PEAR(フォルダ)   ・pear.conf   ・phpプログラム ←配置したプログラム ・wp(フォルダ) phpプログラムにはrequire_once("XML/RPC.php"); と記述しているのですが実行すると以下のエラーが出ます Warning: require_once(XML/RPC.php) [function.require-once]: failed to open stream: No such file or directory in /home/xxx/public/www/pear/xxx.php on line 2 Fatal error: require_once() [function.require]: Failed opening required 'XML/RPC.php' (include_path='“.:/home/xxx/public/www/pear/PEAR”') in /home/xxx/public/www/pear/xxx.php on line 2 php.iniのインクルードパスには「 include_path = ".;/home/xxx/public/www/pear/PEAR";」と記述しています。 問題はパスの記述か、XMLフォルダの存在の有無かのどちらかだろうと判断し、 XMLフォルダの存在を確認するためにphpプログラムの方を以下のように フルパスで記述しました。 require_once("/home/xxx/public/www/pear/PEAR/XML/RPC.php"); すると今度は以下のエラーが出ました。 Warning: include_once(PEAR.php) [function.include-once]: failed to open stream: No such file or directory in /home/xxx/public/www/pear/PEAR/XML/RPC.php on line 594 Warning: include_once() [function.include]: Failed opening 'PEAR.php' for inclusion (include_path='.;/home/xxx/public/www/pear/PEAR') in /home/xxx/public/www/pear/PEAR/XML/RPC.php on line 594 Fatal error: Class 'PEAR' not found in /home/xxx/public/www/pear/PEAR/XML/RPC.php on line 596 これでXMLフォルダが存在することは分かったのであとはインクルードパスの問題と判断しました。 しかし、インクルードパスは何度確認しても「/home/xxx/public/www/pear/PEAR」と合っているように思います。 他に心当たりがある方がいらっしゃいましたら教えていただければと思います。 宜しくお願い致します。

    • 締切済み
    • PHP