i send Packet to client
<iq id="kGufc-4" to="tp#localhsot" from="admin#localhost" type="get"><query xmlns='http://localhost/protocol/disco#info'/></iq>
And received
<iq id="kGufc-4" to="admin#localhost/testchat" from="tp#localhsot" type="error"><error code="404" type="CANCEL"><remote-server-not-found xmlns="urn:ietf:params:xml:ns:xmpp-stanzas"/></error></iq>
what is problem???
You have two problems with that stanza.
1) You've typod 'localhsot' instead of 'localhost'.
2) You're putting a 'from' on the stanza. Assuming you're a client sending this, it is better to not use a 'from', and let the server stamp it itself, as if you get the 'from' wrong, the server will start rejecting stanzas. In your case it's wrong as you're using the bare JID of the client, not the full JID.
Try resolving those first, and then seeing what happens.
Related
I am sending TCP packets just few bits each (one line of text or so). I am sending them to remote server via HTTP proxy however for some reason when the connection with the proxy is slow or interrupted to the server arrives just a fragment of the packet and not entire packet and it causes exceptions on the server side, how it that posible ? Is there any way on the client side how to prevent sending fragment of the packet instead of entire packet ?
Example: I am trying to send this packet:
packetHead: id (1-99)
integer: 1
short: 0
byte: 4
And in my case sometimes happens that to the server arrives just packetHead and integer and the rest of the packet is lost somewhere when the connection with the proxy is bad.
I have no access to modify server source code so I need to fix it on the client side.
Thanks for any tips.
Please show how you send your data. Every time I had a similar problem it was my fault for not flushing the stream. Especially if the stream is compressed you need to call close/complete on the GZIP or similar object to actually send out everything.
I'm using channel-adapters (not gateways) to send data with MessagingTemplate's sendAndReceive from spring integration server to a connected nonspring client (or just telnet).
After receiving the data in the client, somewhen I want to reply data to the server and resolve that sendAndReceive-Waiting. I still want to be able to send other data to the server.
How will sendAndReceive detect a response? Right now I can send whatever I want to the server, it will assume it as a new incoming message.
Is there a predefined way, like prefixing a messageid or do I have to implement it manually by interpreting the incoming messages and somehow "resolve" the sendAndReceive-blocker?
MessagingTemplate.sendAndReceive is based on the TemporaryReplyChannel which is placed to the MessageHeaders and afterward some AbstractReplyProducingMessageHandler just uses that header to send reply back.
Yes, the sending Thread is blocked to wait for the reply throughout that TemporaryReplyChannel.
Hope that can help you a bit.
All other your comment regarding TCP/IP isn't clear for me yet...
ClientA and Client B connect to the NettyServer.
when the connection builds, there is a channel between Client and NettyServer, I want when channel active, I can add Client side info in the channel, so that I can store like Map(ClientInfo,Channel). The on the server side, I can use Map.get(ClientInfo) to get the specific channel, then I can use channel.writeAndFlush() to send message to the specific client.
how to implement it? Use attachment? But, in neety5 API ChannelHandler, the attachment example is not the way I want to use. I wander if I can add attachment at Client side, and I can get it at the Server side?
You can use the AttributeKey or AttributeMap to store your client info, and store them into channel or channelContext, if necessary you can use them using get or set method.
I'm sending messages using java.net. And the server part works with many clients and depending on from what client I receive the message I choose the way to process the message. As I think I need to encolose the username to the message and then get it from there making the rest of the message as it was and sending it for the proceissing. How to do this? How such issues are usually resolved?
When you then receiver data, you can identify the client based on the sender's IP-address. If you still need the clientname, then send it as part of the first message after opening the connection. You can then relate the clientname with its IP-address.
I'm trying to make a port of a chat program a friend of mine made with lacewing and multimedia fusion 2 for android device.
I've managed to create a socket connecting to the listening socket of the server successfully, but I cannot seem to be able to send data to login and enter the chat. The login for now just requires a name, but even if I send a String of data, the server doesn't seem to reply or accept that data to get me over the channel.
I know I could easily port this with other way like using the NDK of the multimedia fusion 2 exporter, but I just want to figure out how this works
PS: I'm using Java and libgdx for the development
You need to read the liblacewing relay protocol:
https://github.com/udp/lacewing/blob/0.2.x/relay/current_spec.txt
On initial connection, you have to send byte 0 to identify that you are not an HTTP client. After this, you can exchange normal protocol messages.
The first message you need to send is the connection request (which may be denied by the server with a deny message). This would be:
byte 0 (2.1.0 request)
(1.2 size)
byte 0 (2.1.0.0 connection request)
string "revision 3" (2.1.0.0 connection request -> version)
When the server responds with response 0 (2.2.0.0 Connect), you then have to set a name before you may join any channels. This is done with message 2.1.0.1 SetName, which is the same structure as above but instead of 2.1.0.0's byte 0, it is 2.1.0.1's byte 1, followed by the name as a string instead of the protocol version.
The server should then respond with 2.2.0.1 SetName, assuming it accepted your name change request. You should process this message in case the server gave you a different name than you requested. Finally, once you have a name, you can join a channel with 2.1.0.2 JoinChannel. The flags you specify here will be used if the channel doesn't exist yet (e.g. nobody is in the chat yet) - these should match the ones in the MMF2 project file. The name should also match.
After all that, you're still not done! You have to process more messages, etc. it's almost like writing the RelayClient class yourself. It's a tough task, but with the protocol specification in hand you should be able to work it all out.