Comments (7)
報告ありがとうございます。
マルチバイト文字列は完全に対応してるつもりなのですが、再現条件等わかったらおしえてもらえると助かります!
from socket.io-client-java.
検証用ファイルを用意してみました。
https://github.com/maimuzo/socket.io-client.java/tree/master/multibyte_test
上記のadb_log.txtを見てもらうのがわかりやすいと思います。
症状としては、
・ASCIIは化けない
・Androidの文字リテラルをサーバに送ると化ける
・サーバの文字リテラルをAndroidに送ると化ける
・Android->サーバ->Androidは化けない
のようです。
ただ、やはり再現性がわからないですが、正常に受信できる時もあります。(これは検証用のソースではなく、別アプリ側で確認しています)
マルチバイト文字を含むデータを何度か受信すると、ある時を境に正常に受信できて、またある時を境にできなくなります。
ソースを見てないですが、チャンクの関係でしょうか?
検証ファイルは用意してないですが、ブラウザ→サーバと、サーバ→ブラウザは大丈夫のようです。
from socket.io-client-java.
詳細な報告ありがとうございます!!
一点気になったのですが、古いバージョンを使っているようなので、最新(0.2.0)にアップデートしてみてもらえますか?
サーバ側のsocket.ioのバージョンも知りたいです。
socket.ioの1.0.xと1.1.0で、若干のプロトコル変更があったためその影響の可能性がありそうです。
from socket.io-client-java.
下記を参考に文字コード推定の検証してみました。
http://qiita.com/shoma2da/items/c77ec534dd36873d73c9
またファイルを更新しました。
https://github.com/maimuzo/socket.io-client.java/tree/master/multibyte_test
ここのcodec_check_node_log.txtがnode側のログですが、
node.js内の文字列リテラルがasciiと判定されていて、送られてきた文字列が(化けてますが)utf-8と判定されています。
もしかすると、node.jsの実行時にマルチバイトをasciiとして評価して実行するようなオプションがあるのかもしれないですが(調べても見つけられませんでした)、もしそんなオプションがなく、node.js内では文字列リテラルはUTF-8扱いされるのであれば、multibyteCharactorsがascii扱いされる理由がよくわからないですね。
一方Androidから受け取った文字がUTF-8なのは想定内なのですが、何故か文字化けしてしまっています。
自分はnode.jsに慣れてないので、このあたりがよくわかってないです。
dump ascii: abcABC123!"#
dump ascii2: abcABC123!#
dump multibyteCharactors: あいうえお
dump multibyteCharactors2: あいうえお
dump data: �����
detect ascii:
{ encoding: 'ascii', confidence: 1 }
detect ascii2:
{ encoding: 'ascii', confidence: 1 }
detect multibyteCharactors:
{ encoding: 'ascii', confidence: 1 }
detect multibyteCharactors2:
{ encoding: 'ascii', confidence: 1 }
detect data:
{ encoding: 'utf-8', confidence: 0.9690625 }
from socket.io-client-java.
「node.jsの実行時にマルチバイトをasciiとして評価して実行するようなオプション」が意味不明だと思いますが、
ruby -K[kcode]
のようなものが、node.jsにもあるのかなと想定していました。
from socket.io-client-java.
すいません。
compile 'com.github.nkzawa:socket.io-client:0.2.0'
これで直りました。orz
こんな初歩的な話だったとは…お手数掛けました。
ちなみに、
received ping, test_type: android json multibyte charactor, data: {"multibyteCharactors":"あいうえお"}
received ping, JSON.parse(data): [object Object]
dump ascii: abcABC123!"#
dump ascii2: abcABC123!#
dump multibyteCharactors: あいうえお
dump multibyteCharactors2: あいうえお
dump data: {"multibyteCharactors":"あいうえお"}
detect ascii:
{ encoding: 'ascii', confidence: 1 }
detect ascii2:
{ encoding: 'ascii', confidence: 1 }
detect multibyteCharactors:
{ encoding: 'ascii', confidence: 1 }
detect multibyteCharactors2:
{ encoding: 'ascii', confidence: 1 }
detect data:
{ encoding: 'ascii', confidence: 1 }
となって、やっぱりマルチバイト文字はasciiと推定されてしまいますね。
これは評価器側の問題な気もしますが。
お手数掛けました。ありがとうございました。
from socket.io-client-java.
一応履歴として。
$ node -v
v0.10.25
├─┬ [email protected]
│ ├── [email protected]
│ ├─┬ [email protected]
│ │ ├── [email protected]
│ │ ├─┬ [email protected]
│ │ │ └── [email protected]
│ │ ├─┬ [email protected]
│ │ │ ├── [email protected]
│ │ │ ├── [email protected]
│ │ │ ├── [email protected]
│ │ │ ├── [email protected]
│ │ │ └── [email protected]
│ │ └─┬ [email protected]
│ │ ├── [email protected]
│ │ ├── [email protected]
│ │ ├── [email protected]
│ │ └── [email protected]
│ ├─┬ [email protected]
│ │ └── [email protected]
│ ├─┬ [email protected]
│ │ └─┬ [email protected]
│ │ ├─┬ [email protected]
│ │ │ └── [email protected]
│ │ ├── [email protected]
│ │ └── [email protected]
│ ├─┬ [email protected]
│ │ ├── [email protected]
│ │ ├── [email protected]
│ │ ├─┬ [email protected]
│ │ │ ├── [email protected]
│ │ │ ├─┬ [email protected]
│ │ │ │ ├── [email protected]
│ │ │ │ ├── [email protected]
│ │ │ │ ├── [email protected]
│ │ │ │ ├── [email protected]
│ │ │ │ └── [email protected]
│ │ │ ├─┬ [email protected]
│ │ │ │ └── [email protected]
│ │ │ ├─┬ [email protected]
│ │ │ │ └─┬ [email protected]
│ │ │ │ └── [email protected]
│ │ │ ├─┬ [email protected]
│ │ │ │ └─┬ [email protected]
│ │ │ │ └── [email protected]
│ │ │ ├─┬ [email protected]
│ │ │ │ └─┬ [email protected]
│ │ │ │ └── [email protected]
│ │ │ ├─┬ [email protected]
│ │ │ │ ├── [email protected]
│ │ │ │ ├── [email protected]
│ │ │ │ ├── [email protected]
│ │ │ │ └── [email protected]
│ │ │ └── [email protected]
│ │ ├─┬ [email protected]
│ │ │ └── [email protected]
│ │ ├── [email protected]
│ │ ├── [email protected]
│ │ ├─┬ [email protected]
│ │ │ └─┬ [email protected]
│ │ │ └── [email protected]
│ │ ├─┬ [email protected]
│ │ │ ├── [email protected]
│ │ │ ├── [email protected]
│ │ │ └── [email protected]
│ │ └── [email protected]
│ └─┬ [email protected]
│ ├── [email protected]
│ ├── [email protected]
│ ├── [email protected]
│ └── [email protected]
from socket.io-client-java.
Related Issues (20)
- how to get session id to send messages
- Client creates a new connection when it reconnects to one of the namespaces.
- io.socket.client.IO::managers leaks resources HOT 1
- socket.io client sometimes sends arrays wrong HOT 5
- can i use multiple socket connection ?
- Android 13 not available HOT 1
- It seems you are trying to reach a Socket.IO server in v2.x with a v3.x client, but they are not compatible HOT 2
- sendBuffer should be accessible
- Getting EVENT_CONNECT_ERROR from Android to Node HOT 1
- Change/update auth or query or extraheaders containing token after connection HOT 1
- Is this project Still Alive? HOT 3
- How to listen to Manager events? (Socket events are working) HOT 2
- Straightforward logging option for Android
- testDecodeError function in Helpers.java error message clean up HOT 2
- Report: ConcurrentModificationException when use AckWithTimout...
- Connection state recovery HOT 1
- NullPointerException: Attempt to invoke virtual method 'java.lang.String java.lang.Object.toString()' on a null object reference HOT 1
- Unable to emit JSON object instead it is emitting Stringified Json in Client Version - 1.0.2 HOT 1
- Implement Connection State Recovery
- it throws java.lang.ClassCastException when sending nested json data. HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from socket.io-client-java.