Exception Message: Message: Operation 'Send' is not valid under state: 7.

Jan 12, 2015 at 6:48 AM
Any idea what this error is telling me? I'm doing this with .NetMF and Gadgeteer and it occurs when the in void SendAMQPMessage(string payload) routine when sender.Send(message); is executed.
#### Exception Amqp.AmqpException - 0x00000000 (1) ####
#### Message: Operation 'Send' is not valid under state: 7.
#### Amqp.Link::ThrowIfDetaching [IP: 0027] ####
#### Amqp.SenderLink::Send [IP: 0007] ####
#### Amqp.SenderLink::Send [IP: 0020] ####
#### ConnectTheDotsGadgeteer.Program::SendAMQPMessage [IP: 00b4] ####
#### ConnectTheDotsGadgeteer.Program::tempHumidity_MeasurementComplete [IP: 00b8] ####
#### Gadgeteer.Modules.GHIElectronics.TempHumidity::OnMeasurementComplete [IP: 0036] ####
#### System.Reflection.MethodBase::Invoke [IP: 0000] ####
#### Gadgeteer.Program::DoOperation [IP: 001a] ####
#### Microsoft.SPOT.Dispatcher::PushFrameImpl [IP: 0054] ####
#### Microsoft.SPOT.Dispatcher::PushFrame [IP: 001a] ####
#### Microsoft.SPOT.Dispatcher::Run [IP: 0006] ####
#### Gadgeteer.Program::Run [IP: 001d] ####
A first chance exception of type 'Amqp.AmqpException' occurred in Amqp.NetMF.dll
Exception caught:Operation 'Send' is not valid under state: 7.

Thanks
Editor
Jan 12, 2015 at 8:14 AM
Hi DukeNukem ;-)

when you try to send, your connection is in an invalid state.
Can you enable trace, following documentation here (https://amqpnetlite.codeplex.com/wikipage?title=Tracing&referringTitle=Documentation), so that we can see underlying AMQP messages exchange ?

Thanks,
Paolo.
Jan 12, 2015 at 8:54 AM
Thanks Paolo, but I think my mistake started when I built the website first and then did the cloud deploy as I think it might have messed up the cloud deploy etc. I deleted everything from Azure and started over starting with the Cloud Deploy stuff first. I did run into one problem that might get someone else and that is from the cloud deploy you will get device connections like:

amqps://D1:XXXXXXXXXXXXXXXXXXXXXXXX%3D@yyyyyyyy.servicebus.windows.net and it appeared that .NetMF didn't like the %3D so I just went to the ehdevices eventhub in the Azure management portal and opened the connection information and grabbed the share keys etc from there and pasted those into my Gadgeteer code and it worked.

I have this working now, so time to see if I can break it again :)
Editor
Jan 12, 2015 at 9:00 AM
As you know (and you done right), the key must be URL encoded but it's new to me that %3D ('=' character) doesn't work. I have already used keys ending with %3D and all works fine.

Paolo.
Sep 2, 2015 at 12:38 PM
Hi Paolo,

I'm using amqp lite with .NET microframework, and I´m receiving the "Message: Operation 'Send' is not valid under state: 7." I used the enable trace you mentioned in another program and I get the following lines:

[06:36.408] RECV AMQP 0 1 0 0
[06:36.416] SEND (ch=0) begin(next-outgoing-id:4294967293,incoming-window:2048,outgoing-window:2048,handle-max:7)
[06:36.420] RECV (ch=0) open(container-id:e57ce02d3e1640759d27e7b69353f8b3_G28,max-frame-size:16384,channel-max:3,idle-time-out:240000)
[06:42.927] RECV (ch=0) begin(remote-channel:0,next-outgoing-id:1,incoming-window:2048,outgoing-window:2048,handle-max:7)
[06:42.935] SEND (ch=0) attach(name:ecobox,handle:0,role:False,source:source(),target:target(address:ecobox/d1),initial-delivery-count:0)
The thread 0x136c has exited with code 259 (0x103).
[06:53.274] RECV (ch=0) attach(name:ecobox,handle:0,role:True,max-message-size:262144)
The thread 0xee0 has exited with code 259 (0x103).
The thread 0x2b14 has exited with code 259 (0x103).
[06:18.675] RECV (ch=0) detach(handle:0,closed:True,error:error(condition:amqp:not-found,description:Entity 'ecobox-ns:Topic:ecobox/d1' was not found. TrackingId:f3f04559-bf41-47c3-899d-876f0940b31a_B5, Reference:41820008-8d5e-43ea-9bec-95146378b81e, Timestamp:9/2/2015 11:08:35 AM))
[06:20.972] SEND (ch=0) detach(handle:0,closed:True)
'DOTNETTEST.vshost.exe' (CLR v4.0.30319: DOTNETTEST.vshost.exe): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_32\System.Transactions\v4.0_4.0.0.0__b77a5c561934e089\System.Transactions.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'DOTNETTEST.vshost.exe' (CLR v4.0.30319: DOTNETTEST.vshost.exe): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_32\System.EnterpriseServices\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.EnterpriseServices.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'DOTNETTEST.vshost.exe' (CLR v4.0.30319: DOTNETTEST.vshost.exe): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_32\System.EnterpriseServices\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.EnterpriseServices.Wrapper.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
A first chance exception of type 'Amqp.AmqpException' occurred in Amqp.Net.dll

Could you help me finding the problem?.

Thanks.
Coordinator
Sep 2, 2015 at 5:34 PM
@rricardog

The topic name you specified "ecobox/d1" does not exist under your Service Bus namespace "ecobox-ns". Can you check if the name is valid?