I'm trying to use RabbitMQ messaging using SignalR.RabbitMQ (https://github.com/mdevilliers/SignalR.RabbitMq) from a queue consumer in c# with the code below:
RabbitMQ.Client.ConnectionFactory factory = new RabbitMQ.Client.ConnectionFactory();
factory.UserName= "username";
factory.Password="password";
factory.HostName="host.name.com";
factory.VirtualHost = "VirtualHost";
factory.Port = 5672;
var exchangeName = "SignalR.Messages";
var configuration = new RabbitMqScaleoutConfiguration(factory, exchangeName);
GlobalHost.DependencyResolver.UseRabbitMq(configuration);
var hubContext = GlobalHost.ConnectionManager.GetHubContext<Chat>();
But unfortunately, fails on:
var configuration = new RabbitMqScaleoutConfiguration(factory, exchangeName);
with the error:
"Field not found: 'RabbitMQ.Client.ConnectionFactory.VirtualHost'."
Same connection works fine on a console app. If I remove the VirtualHost still gives the same error.
No idea what's wrong. Found same error here: https://github.com/MassTransit/MassTransit/issues/204 but doesn't help for me. I use EasyNetQ last version (0.40.3.353) and last version of RabbitMQ Client (3.4.3)
The solution that worked for me invoked using an older version of rabbitmq.client
install-package RabbitMQ.Client -version 3.1.5
Hopefully this helps someone
Related
I have some methods on my base repository to do some batch operations on Cosmos DB, they are like that:
public async Task AddRangeAsync(List<T> entities)
{
var container = _cosmosDbClientFactory.GetContainer(CollectionName);
var entitiesList = entities.Split(_maxItemsPerBatch).ToList();
foreach (var items in entitiesList)
{
var partitionKey = ResolvePartitionKey(items.FirstOrDefault());
var transactionalBatch = container.CreateTransactionalBatch(partitionKey);
items.ToList().ForEach(item => transactionalBatch.CreateItem(item));
var result = await transactionalBatch.ExecuteAsync();
if (!result.IsSuccessStatusCode)
{
throw new CosmosDbBatchOperationException(result.ErrorMessage);
}
}
}
Today I migrated the dotnet version of my project, from dotnet 3.1 to 5, after that I'm getting this error:
System.MissingMethodException : Method not found: 'System.Threading.Tasks.Task1<Microsoft.Azure.Cosmos.Serialization.HybridRow.Result> Microsoft.Azure.Cosmos.Serialization.HybridRow.RecordIO.RecordIOStream.ReadRecordIOAsync(System.IO.Stream, System.Func2<System.ReadOnlyMemory1<Byte>,Microsoft.Azure.Cosmos.Serialization.HybridRow.Result>, System.Func2<System.ReadOnlyMemory1<Byte>,Microsoft.Azure.Cosmos.Serialization.HybridRow.Result>, Microsoft.Azure.Cosmos.Serialization.HybridRow.MemorySpanResizer1)'.
This occurs in this line:
var result = await transactionalBatch.ExecuteAsync();
Version Info:
Microsoft.Azure.Cosmos on v3.17.0
Dotnet 5.0.201
Somebody knows how to solve this?
I've checked all my projects and they are referecing the same sdk version, so I cleaned my solution and deleted all obj and bin folders and tried again but it didn't work.
Then I tried this solution because I was using Microsoft.Azure.Cosmos 3.17.0 with AspNetCore.HealthChecks.CosmosDb 5.0.3, so I downgraded AspNetCore.HealthChecks.CosmosDb to version 3.1.2 and it worked.
It looks like you might be hitting the same problem as discussed in this SDK issue.
A full binary clean and rebuild is worth trying to clear up dependency conflicts for Microsoft.Azure.Cosmos.Serialization.HybridRow.dll. If that doesn't work you could try adding your details to that issue thread.
In my website .Net Framework 4.8, when I update from LinqToTwitter v5.1.1 to 5.1.2 I get an error message when I try to create a new instance of AspNetAuthorizer saying:
"AspNetAuthorizer doesn't contains a definition for CredentialStore"
and "AuthorizeBase is defined in an assembly is not referenced. You
must add a reference to assembly 'LinqToTwitter.netstandard, Version
=5.1.2.0"
Code Example:
return new AspNetAuthorizer
{
CredentialStore = new SessionStateCredentialStore
{
ConsumerKey = MyKey,
ConsumerSecret = Secret
},
GoToTwitterAuthorization =
twitterUrl => url
};
I tried to add a using and searched for the package "LinqToTwitter.netstandard" in nuget but doesn't exists.
Is this version broken?
This was a bug caused by LINQ to Twitter, which has since been fixed and deployed. Here's the fixed/closed issue on the LINQ to Twitter site:
https://github.com/JoeMayo/LinqToTwitter/issues/200
I'm converting some python scripts to its C# equivalent. When I run the following script (using requests module), the sever is happy and there is no issue with it:
auth_header = {'Authorization': 'Bearer ' + access_token}
r = requests.post(api_url + '/v1/instances', headers=auth_header, json =params)
However, when I run the following C# equivalent code, the server returns "405 METHOD NOT ALLOWED":
HttpClient client = new HttpClient();
client.BaseAddress = new Uri(api_url);
client.DefaultRequestHeaders.Authorization = new
System.Net.Http.Headers.AuthenticationHeaderValue("Bearer", access_token);
// Add an Accept header for JSON format.
client.DefaultRequestHeaders.Accept.Add(
new MediaTypeWithQualityHeaderValue(#"application/json"));
string jsonDumps = JsonConvert.SerializeObject(parameters);
var content = new StringContent(jsonDumps, Encoding.UTF8,#"application/json");
var postResult = client.PostAsync(#"v1/pipelines", content).Result; // ERROR:
//StatusCode: 405, ReasonPhrase: 'METHOD NOT ALLOWED'.
It is notable that there is no issue when I run the GET method:
var response = client.GetAsync(#"v1/pipelines").Result;
I do not have access to the sever code. I tried to use Fiddler (similar to wire shark) to see what the python code is sending to the server but using Fiddler causes the python script failed to work properly stating that SSLError: CERTIFICATE_VERIFY_FAILED].
At a quick glance, the C# code looks correct. However, I think you're posting to two different endpoints: Python to /v1/instances and C# to /v1/pipelines. Try swapping them and seeing what happens.
I just created a new deployment slot for my app, imported the publishing profile to Visual Studio, but after deployment I get this error message:
Error 8: An error occurred while creating the WebJob schedule: No website could be found which matches the WebSiteName [myapp__staging] and WebSiteUrl [http://myapp-staging.azurewebsites.net] supplied.
I have 2 webjobs, a continuous and a scheduled webjob.
I already signed in to the correct Azure account, as stated by this answer.
Will I need to set something else up in order to deploy my app to a staging Deployment Slot with webjobs?
My app is using ASP.NET, if it makes a difference?
There are a few quirks when using the Azure Scheduler. The recommendation is to use the new CRON support instead. You can learn more about it here and here.
Jeff,
As David suggested, you can/should migrate to the new CRON support. Here's an example. The WebJob will be deployed as a continuous WebJob.
Keep in mind that in order to use this you need to install the WebJobs package and extensions that are currently a prerelease. You can get them on Nuget.
Install-Package Microsoft.Azure.WebJobs -Pre
Install-Package Microsoft.Azure.WebJobs.Extensions -Pre
Also, as David suggested if you're not using the WebJobs SDK, you can also run this using a settings.job file. He provided an example here.
Program.cs
static void Main()
{
//Set up DI (In case you're using an IOC container)
var module = new CustomModule();
var kernel = new StandardKernel(module);
//Configure JobHost
var storageConnectionString = "your_connection_string";
var config = new JobHostConfiguration(storageConnectionString) { JobActivator = new JobActivator(kernel) };
config.UseTimers(); //Use this to use the CRON expression.
//Pass configuration to JobJost
var host = new JobHost(config);
// The following code ensures that the WebJob will be running continuously
host.RunAndBlock();
}
Function.cs
public class Functions
{
public void YourMethodName([TimerTrigger("00:05:00")] TimerInfo timerInfo, TextWriter log)
{
//This Job runs every 5 minutes.
//Do work here.
}
}
You can change the schedule in the TimerTrigger attribute.
UPDATE Added the webjob-publish-settings.json file
Here's an example of the webjob-publiss-settings.json
{
"$schema": "http://schemastore.org/schemas/json/webjob-publish-settings.json",
"webJobName": "YourWebJobName",
"startTime": null,
"endTime": null,
"jobRecurrenceFrequency": null,
"interval": null,
"runMode": "Continuous"
}
I have a .zip package that I want to install on a development server from my development machine. So I use the msdeploy to do this automatic for me.
msdeploy.exe -verb:sync -source:package=Debug_Services_14.02.20.1413.zip -dest:auto,computername=DEVELOPMENTSERVER,username=ADMIN_USER,password=ADMIN_PWD
But it fails saying that the ERROR_SITE_DOESNT_EXIST.
Info: Adding sitemanifest (sitemanifest).
Info: Adding createApp (MY_SERVICE).
Info: Adding contentPath (MY_SERVICE).
Error Code: ERROR_SITE_DOES_NOT_EXIST
More Information: Site MY_SERVICE does not exist. Learn more at: http
://go.microsoft.com/fwlink/?LinkId=221672#ERROR_SITE_DOES_NOT_EXIST.
Error count: 1.
But I am trying to install it for the first time! What have I missed?
For example. msdeploy api c#.
Execute MSDeploy from C# program code like an API
public static void AppSynchronization(DeploymentBaseOptions depBaseOptions, string appPath)
{
var deploymentObjectSyncApp = DeploymentManager.CreateObject(
DeploymentWellKnownProvider.Package,
appPath, new DeploymentBaseOptions());
deploymentObjectSyncApp.SyncTo(DeploymentWellKnownProvider.Auto, string.Empty,
depBaseOptions, new DeploymentSyncOptions());
}
where
var deployBaseOptions = new DeploymentBaseOptions
{
ComputerName = #"https://WIN-CCDDFDFDFD:8172/msdeploy.axd",
UserName = #"WIN-CCDDFDFDFD\Al",
Password = "1212121",
AuthenticationType = "Basic"
};
appPath = "C:\mySite.zip";