안드로이드 개발 질문/답변
(글 수 45,052)
갤럭시 노트의 기본 웹 브라우져에서 websocket이 지원되지 않는것 같습니다.
브라우져의 내장 오브젝트에는 WebSocket 이 있지만, 서버랑 connect를 하지 않습니다.
다음은 테스트 코드입니다.
해당 코드에서 socket 은 정상 생성됩니다. 생성과 동시에 connecting이 되어야 하나 진행되지 않으며, exception이 catch 되지도 않습니다.
타 모바일기기의 ics 기본 웹 브라우져에서는 정상동작합니다. 또한 동일 장비의 크롬 모바일 베타 브라우져에서도 정상 동작합니다.
브라우져의 내장 오브젝트에는 WebSocket 이 있지만, 서버랑 connect를 하지 않습니다.
다음은 테스트 코드입니다.
<!DOCTYPE html>
<head>
<script>
var socket;
if (typeof(WebSocket) != "function" || window.WebSocket) {
socket = new WebSocket("ws://192.168.0.14:2200/websocket");
try
{
socket.onmessage = function(event) {
alert("Received data from websocket: " + event.data);
}
socket.onopen = function(event) {
alert("Web Socket opened!");
};
socket.onclose = function(event) {
alert("Web Socket closed.");
};
socket.onerror = function(event) {
alert("Web Socket error.");
};
}
catch (e)
{
alert(e);
}
} else {
alert("Your browser does not support Websockets. (Use Chrome)");
}
function send(message) {
if (!window.WebSocket) {
return;
}
if (socket.readyState == WebSocket.OPEN) {
socket.send(message);
} else {
alert("The socket is not open.");
}
}
</script>
</head>
<body>
<form onsubmit="return false;">
<input type="text" name="message" value="Hello, World!"/>
<input type="button" value="Send Web Socket Data" onclick="send(this.form.message.value)"/>
</form>
</body>
</html>
해당 코드에서 socket 은 정상 생성됩니다. 생성과 동시에 connecting이 되어야 하나 진행되지 않으며, exception이 catch 되지도 않습니다.
타 모바일기기의 ics 기본 웹 브라우져에서는 정상동작합니다. 또한 동일 장비의 크롬 모바일 베타 브라우져에서도 정상 동작합니다.
삼성개발자센타에도 올려놓았습니다만, 갤럭시S3와 갤럭시 노트의 기본 웹브라우져에서 웹소켓 문제가 있습니다.
혹시 동일한 문제가 발생하시는분 있나요?




모바일에서는 지원하지 않는듯합니다. node.js 라이브러리 이용하지않고선 불가능합니다.