[Mono-dev] Amazon Lambda With Mono
James Wheeler, PE
james.wheeler.pe at gmail.com
Tue Nov 22 16:38:47 UTC 2016
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
using Amazon.SQS.Model;
using Amazon.SQS;
using System.Diagnostics;
using System.Threading;
using System.Net;
using System.Security.Cryptography.X509Certificates;
namespace TestApp
{
class Program
{
static int Main(string[] args)
{
QueueTest qt = new QueueTest(“YOUR_ACCESS_KEY", “YOUR_SECRET_KEY", “YOUR_QUEUE_URL");
while (true)
{
qt.getMessages();
Thread.Sleep(100);
}
}
}
internal class QueueTest
{
private string QueueUrl;
private string AccessKey;
private string SecretKey;
public QueueTest(string AccessKey, string SecretKey, string queueUrl)
{
this.AccessKey = AccessKey;
this.SecretKey = SecretKey;
this.QueueUrl = queueUrl;
}
public void getMessages()
{
using (AmazonSQSClient sqsClient = new AmazonSQSClient(AccessKey, SecretKey, Amazon.RegionEndpoint.USEast1))
{
ReceiveMessageRequest rm = new ReceiveMessageRequest();
rm.MaxNumberOfMessages = 10;
rm.QueueUrl = QueueUrl;
rm.WaitTimeSeconds = 10;
rm.VisibilityTimeout = 300;
ReceiveMessageResponse rsp = sqsClient.ReceiveMessage(rm);
if (rsp.Messages.Count > 0)
{
foreach (Message m in rsp.Messages)
{
Console.WriteLine(m.Body);
}
}
}
}
}
}
> On Nov 22, 2016, at 10:42 AM, Juan Cristóbal Olivares <cristobal at cxsoftware.com> wrote:
>
> James:
>
> Do you have any code sample so it can be debugged? Thanks
>
> On Tue, Nov 22, 2016 at 10:26 AM, james.wheeler.pe <http://james.wheeler.pe/> <james.wheeler.pe at gmail.com <mailto:james.wheeler.pe at gmail.com>> wrote:
> Thought I posted this yesterday but can't find it.
>
> Forgive me if it shows up twice.
>
> We have a lot of C# code that we would like to run under Amazon Lambda.
>
> Mono would seem to be the most effective way to achieve this.
>
> I have been able to get simple applications to run but things fail
> when I try to use libraries that ultimately make a call via WebRequest.
>
> Here is a partial stack trace....
>
> libc : at (wrapper managed-to-native) System.Platform:uname (intptr)
> at System.Platform.CheckOS () [0x00022] in
> <bd46d4d4f7964dfa9beea098499ab597>:0
> at System.Platform.get_IsMacOS () [0x0000a] in
> <bd46d4d4f7964dfa9beea098499ab597>:0
> at System.Net.WebRequest.GetSystemWebProxy () [0x00149] in
> <bd46d4d4f7964dfa9beea098499ab597>:0
> at System.Net.WebRequest.GetDefaultWebProxy () [0x0003f] in
> <bd46d4d4f7964dfa9beea098499ab597>:0
> at System.Net.WebRequest.get_DefaultWebProxy () [0x00024] in
> <bd46d4d4f7964dfa9beea098499ab597>:0
> at System.Net.GlobalProxySelection.get_Select () [0x00000] in
> <bd46d4d4f7964dfa9beea098499ab597>:0
> at System.Net.HttpWebRequest..ctor (System.Uri uri) [0x0008d] in
> <bd46d4d4f7964dfa9beea098499ab597>:0
> at (wrapper remoting-invoke-with-check) System.Net.HttpWebRequest:.ctor
> (System.Uri)
> at System.Net.HttpRequestCreator.Create (System.Uri uri) [0x00000] in
> <bd46d4d4f7964dfa9beea098499ab597>:0
> at System.Net.WebRequest.Create (System.Uri requestUri) [0x00022] in
> <bd46d4d4f7964dfa9beea098499ab597>:0
> at Amazon.Runtime.Internal.HttpRequest..ctor (System.Uri requestUri)
> [0x00006] in <5fa4eac2df714faba4a923294bf63545>:0
> at Amazon.Runtime.Internal.HttpWebRequestFactory.CreateHttpRequest
> (System.Uri requestUri) [0x00000] in <5fa4eac2df714f
> aba4a923294bf63545>:0
> at Amazon.Runtime.Internal.HttpHandler`1[TRequestContent].CreateWebRequest
> (Amazon.Runtime.IRequestContext requestConte
> xt) [0x0000e] in <5fa4eac2df714faba4a923294bf63545>:0
> at Amazon.Runtime.Internal.HttpHandler`1[TRequestContent].InvokeSync
> (Amazon.Runtime.IExecutionContext executionContext
> ) [0x00020] in <5fa4eac2df714faba4a923294bf63545>:0
> at Amazon.Runtime.Internal.PipelineHandler.InvokeSync
> (Amazon.Runtime.IExecutionContext executionContext) [0x0000e] in
> <5fa4eac2df714faba4a923294bf63545>:0
> at Amazon.Runtime.Internal.Unmarshaller.InvokeSync
> (Amazon.Runtime.IExecutionContext executionContext) [0x00000] in <5f
> a4eac2df714faba4a923294bf63545>:0
> at Amazon.Runtime.Internal.PipelineHandler.InvokeSync
> (Amazon.Runtime.IExecutionContext executionContext) [0x0000e] in
> <5fa4eac2df714faba4a923294bf63545>:0
> at Amazon.SQS.Internal.ValidationResponseHandler.InvokeSync
> (Amazon.Runtime.IExecutionContext executionContext) [0x0000
> 0] in <77e6e07db95447a7b69000e72919cece>:0
> at Amazon.Runtime.Internal.PipelineHandler.InvokeSync
> (Amazon.Runtime.IExecutionContext executionContext) [0x0000e] in
> <5fa4eac2df714faba4a923294bf63545>:0
>
> On the machine I used to create the package to deploy to Amazon Lambda I
> have mono installed and on this machine all the applications work
> flawlessly.
>
> Installing mono for Amazon Lambda is not an option.
>
> I used mkbundle --deps .... to build the package to deploy to Amazon Lambda.
>
> For a while I suspected that the issue might be due to a missing or empty
> mono certificate store. However I implemented the ICertificatePolicy
> interface and accepted everything and that has no affect.
>
> I'd really like to get this working because Amazon Lambda has many practical
> benefits.
>
> Any help or suggestions would be greatly appreciated.
>
> Also, and don't know if this is related or relevant, but I cannot get the
> --static flag to work with mkbundle. The link stage always fails saying it
> cannot find -lmono-2.0.
>
>
>
> --
> View this message in context: http://mono.1490590.n4.nabble.com/Amazon-Lambda-With-Mono-tp4669222.html <http://mono.1490590.n4.nabble.com/Amazon-Lambda-With-Mono-tp4669222.html>
> Sent from the Mono - Dev mailing list archive at Nabble.com.
> _______________________________________________
> Mono-devel-list mailing list
> Mono-devel-list at lists.dot.net <mailto:Mono-devel-list at lists.dot.net>
> http://lists.dot.net/mailman/listinfo/mono-devel-list <http://lists.dot.net/mailman/listinfo/mono-devel-list>
>
>
>
> --
> Atte,
> Juan Cristóbal Olivares
>
>
> cxsoftware.com <http://www.cxsoftware.com/>
> Skype: juancriolivares
> Celular: +56-9 9871 7277
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.dot.net/pipermail/mono-devel-list/attachments/20161122/add529fe/attachment-0001.html>
More information about the Mono-devel-list
mailing list