Apache MINA Java TCP Client-Server Communication - apache-mina

i want co communicate TCP client server communication using apache mina.
can anyone give the code ?
i cant find it in any were....
google is failed to find it.
i want to send and recieve text messages via mina .
so please help me....

It is very simple
on the server side
SocketConnectorConfig SOCKET_CONFIG = new SocketConnectorConfig();
IoFilter charsetFilter = new ProtocolCodecFilter(
new TextLineCodecFactory(Charset.forName("UTF-8")));
SOCKET_CONFIG.getFilterChain().addLast("codec", charsetFilter);
theIoAcceptor.bind(new InetSocketAddress(thePort),
new TriggerReceiverHandler();
here ioAcceptor is of type org.apache.mina.common.IoAcceptor you can instantiate it by using NioDatagramAcceptor
TriggerReceiverHandler is the class that handles the messages and session related events.
it needs to extend the IoHandlerAdapter.
This is for server. Similarly for client the only change is instead of IoAcceptor you use the IoConnector.
Here is an example, well explained too.
http://www.techbrainwave.com/?p=912

Related

What to use so Geode native client pool doesn't hang if no locator found

If I turn off my Geode server and server locator, and then try and connect a client using:
PoolFactory poolFactory = PoolManager
.CreateFactory()
.SetSubscriptionEnabled(true)
.AddLocator(host, port);
if (PoolManager.Find("MyPool") == null)
p = poolFactory.Create("MyPool");
then the poolFactory.Create("MyPool") instruction simply hangs. What do I use to return the Create in this situation of no connection?
It ought to be something like DEFAULT_SOCKET_CONNECT_TIMEOUT in the Javadoc but that doesn't exist in the C# native client...
.SetFreeConnectionTimeout doesn't return either.
Thanks
I don't believe PoolFactory::Create makes any synchronous connections, so I can't explain why it hangs. As this issue would require more back and forth you should post your question on the users#geode.apache.org mailing list.

where exactly the iceCandidate generate in AppRtcDemo?

I am working on webrtc Peer to Peer Calling and successfully running the AppRTCDemo available on WEBRTC site . I have gone through the code and stuck on few points :
1 : When I enter the URL it hit the server and I got response like :
response return from server{"meta_viewport":"","pc_constraints":"{\"optional\": [{\"googImprovedWifiBwe\": true}]}","opusfec":"true","include_vr_js":"","vsbr":"","audio_receive_codec":"opus\/48000","arbr":"","vrbr":"","vsibr":"","token":"AHRlWroqCeuFFBWs4dLJRahxtwho2ldeH_94M_ZipRkK7aIH3nAiSFfScjb_Opz2LwC9xVeWeQrJkRWQAeTsK5sxdJEPoC3jP8uQXkE23QnSANqoBwsHOM4","initiator":1,"ssr":"","room_key":"95505311","pc_config":"{\"iceServers\": [{\"urls\": \"stun:stun.l.google.com:19302\"}]}","stereo":"false","audio_send_codec":"","turn_url":"https:\/\/computeengineondemand.appspot.com\/turn?username=77294535&key=4080218913","me":"77294535","room_link":"https:\/\/apprtc.appspot.com\/?r=95505311&t=json","error_messages":[],"offer_constraints":"{\"optional\": [], \"mandatory\": {}}","asbr":"","media_constraints":"{\"audio\": true, \"video\": true}"}
Here , I just want to know where exactly they are creating iceServer ? On their Server or is there any code inside their channel.html file.
Is there any way to generate iceServer on application without server ? or IceServer is our stun/turn URL sent from server ?
I also have few question on Channel.html :
how exactly channel.html file helping this demo to run ? I have gone through this also and it is calling the onOpen() and which is calling the GAECLIENT class method .
Thanks,
Whichever ice server is going to be used is passed through to the RTCPeerConnection constructor when it is constructed(the object is called pc for the apprtc example). You can see the servers specifically by looking at the pcConfig object.
Once the connection is created(it is not done until a call starts in this example), the localDescription(a RTCSessionDescription object) is set. Once it is set, the WebRTC api will start automatically gathering IceCandidates against the ice servers first introduced when the peer connection was created. Once a new candidate is created, the onicecandidate event is fired(you can see the function used to transfer the candidates if you look at that callback after the pc object is created).
So the general steps are as follows:
Set what iceServers you want to gather candidates against when you create your RTCPPeerConnection object
Set your localDescription to your local RTCSessionDescription object you create(usually created via the success callback you set in the createOffer or createAnswer functions from the peerconnection).
It will start gathering candidates automatically against the servers you set when the peerconnection was constructed and with each candidate the onicecandidate event is fired.
Now, specifically for the apprtc demo page, it uses an open stun server stun:stun.l.google.com:19302 and an array of closed turn servers(that are hosted on Google's cloud) with dynamic credentials that are gathered at page load.

MSMQ complaining about format name while reading messages

I have a non transacitonal private queue(errors) on a remote machine(10.3.35.3), running xp. I am trying to read messages from a machine which runs windows 2008.
I am using "FormatName:Direct=tcp:10.3.35.3\Private$\errors" to access the queue.
I can connect to it.
I can peek.
I have a eventHandler for ReceiveCompleted event, and it get fired once there is a message received from queue, however when I try to convert "source" object to messageQueue.
Friend Sub MyReceiveCompleted(ByVal [source] As [Object], ByVal asyncResult As ReceiveCompletedEventArgs)
Dim objMessageQueue As MessageQueue
Try
objMessageQueue = New MessageQueue
objMessageQueue = CType([source], MessageQueue)
At this point when I try to convert "source" object to MessageQueue object I got exception "The specified format name does not support the requested operation. For example, a direct queue format name cannot be deleted.".
full stack trace of exception
at System.Messaging.MessageQueue.GenerateQueueProperties()
at System.Messaging.MessageQueue.get_QueuePath()
at System.Messaging.MessageQueue.get_QueueName()
at MyReceiveCompleted(Object source, ReceiveCompletedEventArgs asyncResult)
I have tried different format names, no luck. can anyone please explain what is wrong in here? is there any other format name I need to use? can we know what formatname a queue will like beforehand?
Note: in here someone said to use id instead, when I look for id in properties of queue I got all 0s in "Type ID:" field.
Ok I give up on this, it is still not working becuase it is part of a very messy old code. I created my own little application(using the same code, same .net framework) and it can connect to remote queues and read/write/peek. so I believe this was an example of maintenance nightmare of a very very old code base.
during my research I have found some useful links, which may help someone who lands here in future. John Breakwell has following to contribute about remote queue
There is a new security in MSMQ4.0
A registry key in MSMQ3.0
some ports info regarding msmq
some more info about remote msmq 4.0 processing
To see if your msmq is installed in workgroup mode or other one, goto HKLM->Software-> Microsoft->MSMQ->Parameters check REG_DWORD workgroup.
1 is workgroup mode.
0 is AD mode.
and if you want to know the version of your msmq, check version section of this wiki page
I almost forgot to mention that as a rule of thumb I believe we should always read local and write remote, not other way round.

Problems creating OData proxy class - connecting to Azure using Objective C

I hope anyone can help me.
My plan was to connect to Microsoft Azure with my iPhone application. I don't have any experiences using http requests with Objective C yet. So I searched all day long on how to use Azure with Objective C...
I found out that one should use OData to create a proxy class which should help to connect to Azure (http://www.interoperabilitybridges.com/projects/odata-client-for-objective-c-%28ios-macos%29).
So I tried configuring like it says in OData's user guide. But I don't understand how to create a proxy class: I tried to compile the odatagen.xcodeproj but I got a Range or index out of bounds error.
However I typed this in Terminal:
./odatagen /uri=https://{serviceNamespace}.serverbus.windows.net /out= users/xyz/Documents[...] /auth=acs /u=myusername /p=mypassword /at=https://{serviceNamespace}.serverbus.windows.net /sn={serviceNamespace} /ups=no
(Of course replacing {serviceNamespace} with the name of my service namespace etc.)
Did I get all those parameters right? I get an mystical error saying fileRange Error While moving xslt file: (null)... :-(
Or am I totally wrong and connecting my app with Azure works with different tools?
I'm sure you could get it working with what you're doing, but Microsoft have done a lot of the hard work for you. Take a look at the Windows Azure Toolkit for iOS on git hub, it's probably the best place to start.

BizTalk Dynamic WCF-WSHttp Send Port reverting to Http Adapter

I'm trying to send a message to the WCF-WSHttp adapter with a dynamic
send port from an orchestration, but BizTalk seems to always be
reverting back to the HTTP Adapter.
According to the docs that I've been able to find, I should just need
to set the transport type from my expression shape to get BizTalk to
use the WCF-WSHttp adapter, and I AM, but it still seems to be
reverting. Below is an example of my expression shape that's setting
the properties (as you can see, I've tried both
Microsoft.XLANGs.BaseTypes.TransportType and
BTS.OutboundTransportType):
Body(BTS.OutboundTransportType) = "WCF-WSHttp";
SendMessagePort(Microsoft.XLANGs.BaseTypes.Address) =
System.String.Format("{0}/Accept{1}", "http://myserver/myservice/
myservice.svc/Accept{0}", messageInfo.MessageType);
SendMessagePort(Microsoft.XLANGs.BaseTypes.TransportType) = "WCF-
WSHttp";
Probably are Craig :-)
When using a dynamic send port, BizTalk uses the "scheme" part of the url to decide which adapter to use.
When your url starts with "Http://" or "Https://" BizTalk would always use the HTTP adapter.
Similarly url's begining with ftp:// will use the FTP adapter.
Same works for custom adapaters as well - when you install the adapter's configuration you register the moniker to use; for example - the open source Scheduled Task adapter uses schedule:// (I believe).
Using dynamic send ports with WCF is slightly more involved than most other adapaters because of the various configuration that's required but you can find detailed explanation here, just scroll down to the "Dynamic Send Ports" section about half way down.
I ended up resolving my issue, but am still unsure of the reasoning for the behavior I saw.
The Expression shape mentioned in the question was located inside of an Atomic Scope. Once the Orchestration exited the scope containing the Expression shape, the Transport Type was reset back to its original value. Moving the Expression out of the atomic scope resolved the issue, in that the TransportType was set correctly.