Regards,
Serge
http://vertx.io/core_manual_java.html#sockjs
--
You received this message because you are subscribed to the Google Groups "vert.x" group.
To view this discussion on the web, visit https://groups.google.com/d/msg/vertx/-/jxw1x04HMdoJ.
To unsubscribe from this group, send email to vertx+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/vertx?hl=en-GB.
--
Tim Fox
Vert.x - effortless polyglot asynchronous application development
http://vertx.io
twitter:@timfox
--
You received this message because you are subscribed to the Google Groups "vert.x" group.
To post to this group, send an email to ve...@googlegroups.com.
To unsubscribe from this group, send email to vertx+unsubscribe@googlegroups.com.
On 20/07/12 09:53, Sergey Nekoval wrote:
> Ok. It took me a while to build it.
Interesting, what was the issue with building? Should be very quick.
This is normal. If a connection is closed from the closed from the
client side the server will get this exception. Previously these were
supressed, but we dropped the supression because people requested that.
Sergey,
To view this discussion on the web, visit https://groups.google.com/d/msg/vertx/-/7IwkdCSu5H4J.
Hi,
Yes I still have the problem. After playing with timeouts for some time (1.2.0-snapshot) memory usage increases indefinitely (takes several hours to crash).
Wondering how to make test of this...
num #instances #bytes class name
----------------------------------------------
1: 2741077 278351304 [C
2: 3547074 113506368 java.lang.String
3: 32768 79609856 [Lorg.jboss.netty.util.internal.ConcurrentIdentityHashMap$HashEntry;
4: 1783756 57080192 java.util.concurrent.ConcurrentHashMap$HashEntry
5: 591274 47301584 [Ljava.util.concurrent.ConcurrentHashMap$Segment;
6: 1145601 45824040 java.util.concurrent.ConcurrentHashMap$Segment
7: 407657 39135072 org.vertx.java.core.sockjs.impl.Session
8: 1178525 37712800 java.util.concurrent.locks.ReentrantLock$NonfairSync
9: 504895 37481968 [Ljava.util.HashMap$Entry;
10: 1145601 36096936 [Ljava.util.concurrent.ConcurrentHashMap$HashEntry;
11: 897964 35918560 org.jboss.netty.handler.codec.http.HttpHeaders$Entry
12: 910125 29124000 java.util.LinkedList
13: 591274 28381152 java.util.concurrent.ConcurrentHashMap
14: 504836 24232128 java.util.HashMap
15: 723975 23167200 java.util.HashMap$Entry
16: 639092 20450944 org.jboss.netty.buffer.BigEndianHeapChannelBuffer
17: 488788 19048072 [B
18: 516562 16529984 java.util.concurrent.LinkedTransferQueue$Node
19: 381998 15279920 org.jboss.netty.channel.DefaultChannelPipeline$DefaultChannelHandlerContext
20: 591311 14191464 org.vertx.java.core.eventbus.impl.DefaultEventBus$HandlerInfo
21: 591311 14191464 org.vertx.java.core.eventbus.impl.DefaultEventBus$HandlerHolder
22: 591226 14189424 org.vertx.java.core.eventbus.impl.DefaultEventBus$Handlers
23: 865607 13849712 java.lang.Object
24: 95499 11459880 org.jboss.netty.channel.socket.nio.NioAcceptedSocketChannel
25: 95499 10695888 sun.nio.ch.SocketChannelImpl
26: 407657 9783768 org.vertx.java.core.sockjs.impl.EventBusBridge$1
27: 407657 9783768 org.vertx.java.core.sockjs.impl.EventBusBridge$2
28: 235517 9420680 org.jboss.netty.channel.DefaultChannelFuture
29: 235294 9411760 org.jboss.netty.buffer.DynamicChannelBuffer
30: 381170 9148080 java.net.InetSocketAddress
31: 92501 8140088 [Lorg.jboss.netty.handler.codec.http.HttpHeaders$Entry;
32: 328708 7888992 org.vertx.java.core.sockjs.impl.EventBusBridge$2$1
33: 235398 7532736 org.jboss.netty.channel.DownstreamMessageEvent
34: 91784 6608448 org.vertx.java.core.http.impl.DefaultWebSocket
35: 407657 6522512 org.vertx.java.core.sockjs.SockJSSocket$1
36: 407555 6520880 java.util.HashMap$EntrySet
37: 191000 6112000 java.net.Inet4Address
38: 94753 6064192 org.vertx.java.core.http.impl.ServerConnection
39: 123008 5904384 org.jboss.netty.buffer.CompositeChannelBuffer
| (function() { | |
| var Socket = function(host, port, path) { | |
| var ref = this; | |
| this.host = host; | |
| this.port = port; | |
| this.path = path; | |
| this.debug = 0; | |
| if (typeof console === undefined) { | |
| this.debug = 0; | |
| } | |
| }; | |
| Socket.prototype.doConnect = function() { | |
| var ref = this; | |
| try { | |
| if (typeof this.sock !== 'undefined') { | |
| this.sock.close(); | |
| } | |
| } catch(e) { | |
| if (ref.debug === 1) { | |
| console.log(e); | |
| } | |
| } | |
| this.sock = new SockJS('http://'+this.host+':'+this.port+'/'+this.path); | |
| this.lastSeen = new Date(); | |
| this.sock.onopen = function() { | |
| var obj; | |
| ref.onopen(); | |
| ref.sock.onmessage = function(e) { | |
| if (ref.debug === 1) { | |
| var blah = JSON.parse(e.data); | |
| if (blah.payload.action) console.log('<~~~ ', blah.payload.action, blah.payload); | |
| else console.log('<~~~ ', blah.payload); | |
| } | |
| ref.lastSeen = new Date(); | |
| obj = JSON.parse(e.data.toString()); | |
| if (obj.system === '1') { | |
| ref.sock.send( | |
| JSON.stringify({ | |
| system:'1', payload:obj.payload | |
| }) | |
| ); | |
| } else { | |
| ref.onmessage(obj.payload); | |
| } | |
| }; | |
| }; | |
| setInterval(function() { | |
| if (new Date()-ref.lastSeen>10*1000) { | |
| if (ref.debug === 1) { | |
| console.log('not connected, re-connecting...'+(new Date()-ref.lastSeen)); | |
| } | |
| setTimeout(function() { | |
| ref.doConnect(); | |
| }, 4000+Math.random()*4000); | |
| } | |
| }, 10*1000); | |
| }; | |
| Socket.prototype.onopen = function() { | |
| }; | |
| Socket.prototype.send = function(obj) { | |
| if (this.sock.readyState === 1) { //WebSocket.OPEN | |
| if (this.debug === 1) { | |
| console.log('****~>', JSON.stringify({payload:obj})); | |
| } | |
| this.sock.send(JSON.stringify({system:'0', payload:obj})); | |
| } else { | |
| if (this.debug === 1) { | |
| console.log("The socket is not open."); | |
| } | |
| } | |
| }; | |
| Socket.prototype.onmessage = function(obj) { | |
| }; | |
| var chat = function() { | |
| this.sock = new Socket('chost2', 80, 'chat'); | |
| this.sock.doConnect(); | |
| }; | |
| })(); | |
--
You received this message because you are subscribed to the Google Groups "vert.x" group.
To view this discussion on the web, visit https://groups.google.com/d/msg/vertx/-/M-X7GL0leNAJ.
To view this discussion on the web, visit https://groups.google.com/d/msg/vertx/-/D4BijG6IsMIJ.
To unsubscribe from this group, send email to vertx+unsubscribe@googlegroups.com.
Here is a Groovy verticle (pretty much a bit modified bridge example):
def server = vertx.createHttpServer()
// Serve the static resources
server.requestHandler { req ->
if (req.uri == '/') req.response.sendFile('my-live/index.html')
if (req.uri == '/vertxbus.js') req.response.sendFile('my-live/vertxbus.js')
}
def inboundPermitted = []
def outboundPermitted = [[:]]
vertx.createSockJSServer(server).bridge(prefix: '/eventbus', inboundPermitted, outboundPermitted)
server.listen(80)
// Run a private message server using 8080
def eb = vertx.eventBus
vertx.createHttpServer().requestHandler { request ->
if (request.uri == '/publish/movie' && request.method == 'POST') {
def body = new Buffer(0)
request.dataHandler { buffer -> body << buffer }
request.endHandler {
println "[${body as String}]"
JsonObject json = new JsonObject(body as String)
eb.publish("new.movie", json)
request.response.with {
statusCode = 201
statusMessage = "Movie accepted"
end()
}
}
} else if (request.uri == '/') {
request.response.sendFile('my-live/index.html')
} else if (request.uri == '/vertxbus.js') {
request.response.sendFile('my-live/vertxbus.js')
} else {
request.response.with {
statusCode = 404
statusMessage = 'Unavailable'
end()
}
}
}.listen(8080)
[dev@localhost ~]$ wget http://198.58.99.196/web/web.zip--2012-10-11 04:46:24-- http://198.58.99.196/web/web.zipConnecting to 198.58.99.196:80... connected.HTTP request sent, awaiting response... 200 OK
Length: 34566 (34K) [application/octet-stream]
Saving to: `web.zip'100%[======================================>] 34,566 63.9K/s in 0.5s2012-10-11 04:46:25 (63.9 KB/s) - `web.zip' saved [34566/34566][dev@localhost ~]$It appears valid to me, can you try again?
> vertx+unsubscribe@googlegroups.com.
Are you using master? I recently fixed a memory leak there.
sockServer.installApp(config, new Handler<SockJSSocket>() { public void handle(final SockJSSocket sock) {
.....
sock.dataHandler(new Handler<Buffer>() { public void handle(Buffer data) {
JsonObject object = new JsonObject(data.toString()); String type = object.getString("type", "empty");
> vertx+unsubscribe@googlegroups.com.