I am trying a Cloud application using Raspberry Pi 3 with Windows 10 IOT Core.
I have already completed a Universal App which collects data and messages it to the cloud, which is functional.
Next, I try to write a little Application to receive these messages from Azure using the Message Bus.
I have registered my device in Azure (trial version) and got some connection strings and Ids. I use this same connection string to connect to the event message service:
string IotHubUri = "HostName=<My>Hub.azure-devices.net;DeviceId=<MyRaspiPC>;SharedAccessKeyName=iothubowner;SharedAccessKey=<The primary key>"
string iotHubD2cEndpoint = "messages/events";
EventHubClient client = EventHubClient.CreateFromConnectionString(
IotHubUri,
iotHubD2cEndpoint);
The IotHubUri string originally had no "SharedAccessKeyName" in it, I filled it in after getting an exception telling me that there is missing information.
With this KeyName provided, I get another Exception
Hostname could not be parsed
Since I am using the same pattern as I have found in all books and other information I found on the Internet, I am simply stunned and have no idea how to go on.
Related
I have two console applications, A and B.
The application A was created for test purposes and works as expected.
The application B does not work although it is basically a copy-paste of A's code:
System.Console.Write("User Name: ");
string username = System.Console.ReadLine();
System.Console.Write("Password: ");
string password = ConsoleReadPassword();
System.Console.WriteLine();
//user and password required because I am also a privileged user
//(member of mqm group)
MQEnvironment.UserId = username;
MQEnvironment.Password = password;
//for application B this line throws exception with code 2538
var queueManager = new MQQueueManager("TEST.QUEUE.MANAGER", "CLIENT.CONN.CHANNEL", "localhost(1414)");
Error code 2538 means "Host not available" which is weird because application A has no problems connecting to the same host.
This is how the MQ Server looks in MQ Explorer:
Queue managers:
Queues:
Listeners:
Channels:
Two server channels
Channel auth records:
Default channel authentication record which prevents MQ admins from connecting to queue managers. It was slightly modified (added ~ prefix) so now it does not block anyone.
The MQ Server and applications are running on the same machine so imho network problems are excluded.
The queue manager error log does not report any errors but the general error log looks like this:
08/02/2016 15:15:23 - Process(13720.10) User([username])
Program(B.EXE) AMQ9202: Remote host 'localhost(1414)' not
available, retry later.
EXPLANATION: The attempt to allocate a conversation using TCP/IP to
host 'localhost(1414)' for channel (Exception) was not successful.
However the error may be a transitory one and it may be possible to
successfully allocate a TCP/IP conversation later.
For both application I use the same version of amqmdnet.dll: 8.0.0.4
Both programs A and B have the same target framework: 4.5
While testing I didn't tried to run the both applications in the same time and I checked in MQ Explorer if the channel is free (Inactive).
I also tried to change the name of resulting assemblies but with no effect.
Does anyone know what could cause application B to be unable to connect?
When using the hostname localhost networking is still involved, it just all happens inside the one machine. If application A is running in the same machine as your queue manager then having application A connect using the connection name localhost(1414) will certainly work but it is not necessary to make the connection like this (i.e. using TCP/IP) you could instead make a local bindings connection.
On the other hand, if you are using TCP/IP because application B is running on a different machine to where the queue manager is running, then using localhost(1414) will not work because localhost on one machine does not connect to localhost on another machine. You should change what is specified in the application's connection name from localhost(1414) to use the IP address (or hostname) of the queue manager's machine (followed as before with the port number).
Although I was unable to find the cause of the problem the solution was to simply
delete and re-create the project.
This is what I tried before and what led me to this action:
In B I removed and then added back the reference to amqmdnet.dll - not working
I created yet another project (let's call it C): console application, same code - working
I renamed* the C project with the same name as B - still working
*The name of the non-working project contained a dot so I thought that this could cause the problem - it was not the case.
I want to get notifications when a new feed has landed on a designated page (by page id). After what I understand, the Realtime-update og Graph API should be able to do this trick according to https://developers.facebook.com/docs/graph-api/real-time-updates/v2.4.
So I want to add a new subscription, which I try to do with the following code:
dynamic result = client.Post(urlPath, new
{
#object = "page",
callback_url = callbackUrl,
fields = "feed",
verify_token = "654321",
access_token = accessToken
});
return result;
But when I try to run this, I'm getting the following error code:
(OAuthException - #2200) (#2200) callback verification failed: Received HTTP code 502 from proxy after CONNECT"
What do I miss?
The callback url is https://127.0.0.1:8989/ and I have a TcpListener running on the port, which does not seem to get any response/request incoming...
The application is a C# console application, so no fancy asp.net stuff or something. I'm using the Facebook .net SDK.
Should I FacebookClient.VerifyPostSubscription() or anything else that I missed out?? Maybe the SDK wraps a handle?
So the answer I'm looking for is:
- How do I create/add a subscription for feeds of a facebook page, using the .net SDK on a windows console project??
UPDATE:
I changed the loopback with a domain name, that I the NAT to my target machine, and now I actually get some encrypted data on my TcpListener!
So, the question now is, how do I respond correctly to this received respons, only by using a Tcp Client??
How you have to respond is exactly outlined in the docs you linked:
https://developers.facebook.com/docs/graph-api/real-time-updates/v2.4#setupget
It's not really clear what you mean with "TCP listener". You need to have some logic why can send HTTP responses to the Facebook servers, otherwise your service will be disregarded after some time, meaning no updates will be send.
Typically, this is implemented as a script/application in a web/application server.
Please note: The "C# SDK" is a third-party SDK and not officially supported by FB.
I have created a new WorkerRole using the template for a QueueWorkerRole in VS 2013 and it creates code that looks like this:
// Create the queue if it does not exist already
var connectionString = CloudConfigurationManager.GetSetting("Microsoft.ServiceBus.ConnectionString");
var namespaceManager = NamespaceManager.CreateFromConnectionString(connectionString);
if (!namespaceManager.QueueExists(QueueName))
{
namespaceManager.CreateQueue(QueueName);
}
// Initialize the connection to Service Bus Queue
_client = QueueClient.CreateFromConnectionString(connectionString, QueueName);
The problem I ma having is setting the Microsoft.ServiceBus.ConnectionString correctly so that it will work with my local development queues running in the emulator. By default it sets it up like this:
<appSettings>
<!-- Service Bus specific app setings for messaging connections -->
<add key="Microsoft.ServiceBus.ConnectionString" value="Endpoint=sb://[your namespace].servicebus.windows.net;SharedSecretIssuer=owner;SharedSecretValue=[your secret]" />
</appSettings>
And I'm guessing this will work fine when I have a hosted service to connect to but I am just trying out some things locally and can't get it to connect.
I have tried "UseDevelopmentStorage=True" and I've tried using the address I found when viewing the Storage Emulator UI "127.0.0.1:10001" as well as the Local Emulator using Standard Format I found here: http://www.connectionstrings.com/windows-azure/ (DefaultEndpointsProtocol=https;AccountName=devstoreaccount1;
AccountKey=Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==;) but I am having no luck.
Sometimes I am seeing "The Service Bus connection string contains invalid property" in the Compute Emulator UI and other times I get an error that it can't connect.
Thanks.
The problem you are having here is that you are attempting to plug a queue connection string into a Service Bus Connection String Creator. Those two connection strings are inherently different.
To use development storage you need to set the value of the app setting key you wish to use to: "UseDevelopmentStorage=true" as seen in this stack overflow:
Windows Azure Storage Emulator Connection String for ASP.NET MVC? This will work for STORAGE (not service bus)
Trying to connect to a windows azure queue from a windows service (ie. not running in azure, just on my desktop, for now, but eventually on a self-hosted windows server).
The connection string generated by the dashboard is in the following form:
Endpoint=sb://MyServiceBus.servicebus.windows.net/;SharedAccessKeyName=MySasName;SharedAccessKey=*****
I'm trying to initialize the CloudStorageAccount, but am receiving a format exception (as noted in the title).
string str = ConfigurationManager.AppSettings["StorageConnectionString"];
CloudStorageAccount storageAccount = CloudStorageAccount.Parse(
str);
This seems to match all of the documentation ... can anyone clear up what might be going on?
I am trying to connect to a remote queue using c#.
I tried many ways to connect to the remote queue but it always fails with common errors like: MQRC_CHANNEL_CONFIG_ERROR or MQRC_HOST_NOT_AVAILABLE.
What I am doing is this:
string channel = "QM_TEST.SVRCONN";
string hostname = "<serverIp>";
string queueName = "QM_TEST";
string port = 1414;
props.Add(MQC.HOST_NAME_PROPERTY, hostname);
props.Add(MQC.CHANNEL_PROPERTY, channel);
props.Add(MQC.PORT_PROPERTY, port );
props.Add(MQC.TRANSPORT_PROPERTY, MQC.TRANSPORT_MQSERIES_MANAGED);
MQQueueManager mqQueue = new MQQueueManager(queueName, props);
I have tried changing this but all failed.
I think that my problem is the server configurations..
can you point me to a full guide to how to configure a server and connect to it with .net?
My problem is connecting to a REMOTE server using .net and not to a local server.
Thank you!
The problem was that the CCSID between the client and the server were different.
http://publib.boulder.ibm.com/infocenter/wmqv7/v7r0/index.jsp?topic=%2Fcom.ibm.mq.csqzaf.doc%2Fcs12480_.htm
On the client side I had to put
Environment.SetEnvironmentVariable("MQCCSID", "437");
Thats why I got:
MQRC_CHANNEL_CONFIG_ERROR
I'm guessing the problem (or at least a problem) is here:
MQQueue mqQueue = new MQQueueManager(queueName, props);
This should be
queueManager = new MQQueueManager(queueManagerName, properties);
If you have installed the WebSphere MQ client to the default location, there are many sample programs under the following directory:
C:\Program Files (x86)\IBM\WebSphere MQ\tools\dotnet\samples\cs\base\
There are a number of sample programs there for various tasks. If you have the latest V7.1 client installed then you will see the following programs:
SimpleAsyncPut
SimpleClientAutoReconnectGet
SimpleClientAutoReconnectPut
SimpleGet
SimpleMessageProperties
SimplePublish
SimplePut
SimpleReadAhead
SimpleSharingConversation
SimpleSubscribe
SimpleXAGet
SimpleXAPut
There are also WCF and XMS samples.
If you need the client code, please see my response to another SO question here for links.
Update:
Here's the normal diagnostic process.
If the WMQ components were installed by relocating libraries or classes from somewhere else, perform an install using the full vendor-supplied client media. This includes troubleshooting utilities such as trace, dspmqver, etc. It also resolves any library or class mismatch issues.
Use the pre-compiled client programs to test the connection. The amqsputc, amqsgetc and amqsbcgc programs require the MQSERVER environment variable as described here. The Q program from SupportPac MA01 is a separate download but has the advantage of NOT requiring any environment variables, CCDT files or other dependencies.
If the sample programs fail, check the QMgr's error logs at [WMQ install]/qmgrs/[QMgr name]/errors/AMQERR01.LOG for messages. Also check for FDC files and errors in [WMQ install]/errors.
If no errors on the QMgr side, attempt the connection again while using a client-side trace as described here and here.
Most client problems are resolved through installation of the full WMQ client as supplied by IBM. (Conversely that implies most people are installing by grabbing DLL or JAR files.) If the problem persists, error log inspection on the QMgr and client side usually reveals the underlying cause. If these do not work then tracing usually diagnoses the remaining issues.
UPDATE 2:
Per the error messages posted at MQSeries.net, the channel has a security exit set. A security exit is external code that the channel calls out to when starting a channel. There is no way to know what the exit expects or does without having access to the code or docs of the exit. If the exit is written in-house, you'll need to talk to the programmer to figure out what it requires. If the exit is a commercial product then you will need to get the documentation for it.
Alternatively, alter the channel so that SCYEXIT is blank to disable the exit.
The data posted at MQSeries.net was as follows:
MQ9575: DCE Security: failed to get the user's login name.
EXPLANATION:
System call 192.168.50.55 to get the login name of the user running WebSphere
MQ client application process 5 failed with error value -1. This occurred in
security exit function create_cred. The exit will now attempt to open channel
using the DCE default login context.
ACTION:
If you wish to run using the DCE default login context take no action. If you
wish to run using the user's login name as the DCE security exit principal
examine the documentation for the operating system on which you are running MQ
clients and reconfigure the operating system as necessary to allow the
192.168.50.55 call to succeed.
Note that it states the call is failing in the security exit.