Problems withSocket Communication

urknall
Member Posts: 4
Hello,
I have a Problem with Navision Communication Component version 2.0 and Navision Socket Bus Adapter. (Sorry for my bad english :roll: )
Why isn't start my InMessage Event? see my code of a little Socket Client Application. An external Socket Server is sending data to him. My outsending Data are OK.
Thanks for your help!!!
Urknall
I have a Problem with Navision Communication Component version 2.0 and Navision Socket Bus Adapter. (Sorry for my bad english :roll: )
Why isn't start my InMessage Event? see my code of a little Socket Client Application. An external Socket Server is sending data to him. My outsending Data are OK.
OnRun() IF ISCLEAR(ComCom) THEN CREATE(ComCom); IF ISCLEAR(SBA) THEN CREATE(SBA); ComCom.AddBusAdapter(SBA, 0); IF ISCLEAR(OutMsg) THEN BEGIN OutMsg:= ComCom.CreateoutMessage('Sockets://locelhost:8888'); OutS:= OutMsg.GetStream(); OutS.WRITE('Hello World!'); //Test Kommuikation OutMsg.Send(0); END ELSE BEGIN OutS:= OutMsg.GetStream(); OutS.WRITE('Hello World!!!'); //Test Kommuikation OutMsg.Send(0); END; ComCom::MessageReceived(VAR InMessage : Automation "''.IDISPATCH") InMsg:= InMessage; InS:= InMsg.GetStream(); WHILE NOT (InS.EOS) DO BEGIN InS.READ(TXT); MESSAGE(TXT); END;
Thanks for your help!!!
Urknall
0
Comments
-
Hello Urknall,
I’ve had the same problem. As far as I know, it’s not possible to use the event "messageReceived" on a client.
I’ve solved the problem with the onTimer property in a from. This onTimer event triggers a function in a single instant codeunit with checks if something’s is available on the winsock buffer. I’m not using the comcom adapter but I’m using the winsock.ocx. It’s not very elegant but It works.
Good luck
Henry0 -
Hello, Henry!
Thanks for your fast answerbut you have bad news!!! The solution that you propose me, i have implement a year ago.
This solution was very inefficient!!! It is a performence-Killer!
An other alternative is develop a Server Socket with navision, but i have the same problems. I don't understand this!
Regards
Urknall0 -
Hello Urknall,
Yes, it’s true it is not the best performance solution. But the a Navision socket server sould be no problem.
As you have installed a Navision client there is a small but very usefull (hidden) OnlineHelp. You'll find it under c:\program files\shared files\navision\communication component\devguide.chm.
This OnlineHelp gives examples (sending and receiving data) for all kinds of adapters (socket, message queue and named pipe). I think there you'll find all you need.
Hope I could help.0 -
I know this file! But there is non example for Data receiving and sending in one process!
I have build an Server Socket application, but i received only one message in my event trigger.OnRun() IF ISCLEAR(ComCom) THEN BEGIN CREATE(ComCom); IF ISCLEAR(SBA) THEN CREATE(SBA); ComCom.AddBusAdapter(SBA, 0); SBA.OpenSocket(8888,''); END ELSE begin; CLEAR(ComCom); CLEAR(SBA); END; ComCom::MessageReceived(VAR InMessage : Automation "''.IDISPATCH") IInMsg:= InMessage; InS:= IInMsg.GetStream(); WHILE NOT (InS.EOS) DO BEGIN InS.READ(TXT); MESSAGE(TXT); END; IF IInMsg.ExpectReply THEN BEGIN //MESSAGE('Antwort erforderlich!!!'); IOutMsg := IInMsg.CreateReply; OutS:= IOutMsg.GetStream(); IOutMsg.Send(0); END; //IInMsg.CommitMessage();
When i set the CommitMessage Command the Connection will be killed!
And how can i send my data to connected clients? How can i identify connected clients? thats all my problems
Kind Regards
Urknall0 -
Hello Urknall,
Here is a example for Data receiving and sending in one process. It’s is possible to identify connected clients by there IP address using The Source Property. This property reveals the IP address of the sender of the message.OnRun() IF ISCLEAR(ComCom) THEN IF NOT CREATE(ComCom) THEN ERROR('Failed to create Communication Component'); IF ISCLEAR(SBA) THEN IF NOT CREATE(SBA) THEN ERROR('Failed to create SBA'); // Add the SBA to the Comunication Component ComCom.AddBusAdapter(SBA, 0); //Open the Socket on Port 5678, the name of the Socket is socketname SBA.OpenSocket(5678, 'socketname'); SBA.ReceivingTimeout := 20000;
ComCom::MessageReceived(VAR InMessage : Automation "''.IDISPATCH") InMsg := InMessage; InStr := InMsg.GetStream(); //Create a string InStr.READTEXT(str); IF str <> '' THEN MESSAGEstr := 'Hello ' + str + InMsg.Source; //Create Reply OutMsg:= InMsg.CreateReply; //Write something into the OutStream OutStr:= OutMsg.GetStream(); //Copy Incoming Msg into Outgoing Msg OutStr.WRITETEXT(MESSAGEstr); //Send Reply Msg - the 0 means send it right away. OutMsg.Send(0); InMsg.CommitMessage();
The Navision Socket Bus adapter is a very strange component. :roll: For example it can have multiple connections, but I can only process one connection a time. And yes it kills the connection when the CommitMessage is send. There’s nothing you can do about it. Navision 4.0 will be more .NET based so perhaps there will be a better socket bus adapter in Navision 4.0.
Good luck,
Henry0 -
You also have the counterpart of this code, the code that sends the message and receives the answer in navision?
Rgds
BennyRgds
Benny Giebens0 -
Continuous socket server in Navision = not possible.
Navision 4.0 = no improvement.
You'll have to write your own external socket server component and send it into something Navision understands, like a message queue.0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions