Giter VIP home page Giter VIP logo

griffin.framework's People

Contributors

campersau avatar cjmurph avatar crisim avatar gauffininteractive avatar jakubmacek avatar jgauffin avatar mwuerth avatar phaza avatar renniepet avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

griffin.framework's Issues

Issue: Channel got disconnected

I am able to implement a client socket using the ChannelTcpClient. However whenever I connect to a socket server to execute some commands I got channel got disconnected. Am I doing something wrong?.

Handle Message without request

Hi, i am just starting to use Griffin.Framework, and i am looking for handle message without sending request on client side

Ex:
(CLIENT) request_friendslist
(SERVER) reply_friend1
(SERVER) reply_friend2
(SERVER) reply_friend3

Sorry for my bad english.
Best regards SheppeR

connection.Insert returning null - PK problem?

Hi,

I've got a simple POCO ('Model.Client') which matches exactly my database fields. The mapper for that is defined as:

public class ClientMapper : CrudEntityMapper<Model.Client>
{
    public ClientMapper() : base("Clients")
    {
    }
}

...which I believe is the correct way to define a mapper if the model properties match the database fields.

Now, if I insert an instance of this model as so:

var ret = _conn.Insert(client);

...the row is added to the database table correctly, but ret is null. I believe this should either be the identity of the newly-inserted row, or an instance of the model that was inserted with the .Id property set appropriately.

My database correctly has an auto-incrementing primary key column named Id, and my entity object has a matching int Id { get; set; } property defined.

No exceptions appear to be thrown. I'm using the latest version of Griffin.Framework as available on NuGet.

It's almost as if the mapper hasn't picked up the presence of the Id field. Is there any way to see what's going on inside the mapper during use?

Any advice greatly appreciated!

QueryConstraints, not found in the new framework

Hi,
You said here:
https://github.com/jgauffin/Griffin.Framework
*This library hass been merged into Griffin.Framework - Got a lot more functions in Griffin.Framework. *
so i went to the "Griffin.Framework", and searched for the "QueryConstraints" and its other related classes, but nothing was found, i only found an object that is passed as a parameter, called "constraint" but its of type object, not a typed class as it is in the old framework.

So am i missing something in my search, or you have changed the names, or changed your good idea, to a better one?

Regards.

Close on TcpChannel blocks for 5 seconds needlessly

This is more of a question than a bug per se, but I am using your network client class in an ASP.Net controller to call into a backend service. Once the controller is done, dispose gets called to clean up DI injected client classes. In dispose for my client class, I am calling dispose on the TcpChannelClient, which is ultimately closing the socket. But in the act of closing the socket, you put in an arbitrary 5 sec wait after the shutdown. Why not use disconnect, which only blocks until sending/receiving is done? Or if you are concerned with disconnect blocking forever, call close with a timeout?

Channel : Data Polling

I have implemented the client using the ChannelTcpClient. I can send data to the upstream socket server and receive response. However I want to be reading some data via a different thread and at the same time sending data and reading response as usual. What I observe is that the polling thread has already remove my response data. So I went to the ChannelTcpClient ReceiveAync and I discovered that it uses a concurrent queue which means FIFO. I would like to know whether I am doing the right thing or there is a way to do polling as well as send request and receive response using ReceiveAsync.

the HttpFileCollection isn't enumerable

I have a service which accept multipart/form-data post request, but i don't know the filenames i'll receive.
pls add a getEnumerator just like in the ParameterCollection.

HttpListener - ListenerError - PoolEmptyException

I'm using the HttpListener process. I'm load testing to check stability. Basically firing one request after another, and then multiple sessions firing multiple requests.
I'm finding that the HttpListener triggers a ListenerError event - this seems to be caused by the following exception:

Griffin.Net.Buffers.PoolEmptyException

At this point the listening stops, and no further requests can be made.

From digging through the source I can see this is to do with thread safe concurrentstack use - just can't see the fix.

My code is pretty straight forward...
var listenerInternal = new Griffin.Net.Protocols.Http.HttpListener(); listenerInternal.MessageReceived += OnMessageReceived; listenerInternal.ListenerError += OnListenerError; listenerInternal.MessageSent += OnMessageSent; listenerInternal.BodyDecoder = new Serializers.PlainTextSerializer();

` private static void OnMessageReceived(ITcpChannel channel, object message)
{
try
{
//Thread.CurrentThread.Name = string.Format("{0}:{1}", DateTime.Now.ToShortDateString(), messageCounter);
Thread.CurrentThread.Name = Guid.NewGuid().ToString("N");
var request = (HttpRequest)message;

            log.InfoFormat("{0} {1}", request.HttpMethod, request.StatusLine);
            bool internalRequest = clsUtils.IsLocalIpAddress((System.Net.IPEndPoint)request.RemoteEndPoint); //ignore this one
            internalRequest = clsUtils.isIPLocal(((System.Net.IPEndPoint)request.RemoteEndPoint).Address);

            var response = (HttpResponse)request.CreateResponse();
            using (RequestHandler r = new RequestHandler(ref channel, ref message, internalRequest))
            {
                response = r.getResponse();
                channel.Send(response);
                if (request.HttpVersion == "HTTP/1.0")
                    channel.Close();
                r.waitForTasks();
            }

The RequestHandler has been super simplified to just return something quick and meaningless public RequestHandler(ref ITcpChannel channel, ref object message, bool internalRequest)
{
var incomingMessage = new IncomingMessage();
var data = "";
var NVP = new System.Collections.Specialized.NameValueCollection();
request = (HttpRequest)message;
response = (HttpResponse)request.CreateResponse();

        ////////////////////////////////////////////////
        response.StatusCode = (int)HttpStatusCode.OK;
        response.Body = new MemoryStream(Encoding.UTF8.GetBytes(string.Format("Up and running\nProcessed {0} requests", requestCount)));
        response.ContentType = "text/plain";
        return;
    }`

I'm using the latest Griffin.Framework nuget v2.1.1
Can you see where i'm going wrong?

It looks like either a process that should be cleaning up isn't, or i'm just doing too much - In these recent tests, it probably amounts to 7 sessions processing 20 or so requests one after the other.

image

Thanks for your help.

Server App: Client is disconnected after connection

So far the library is very useful and insightful and very helpful to implement protocol driven application.However I am facing some interesting issue. I have done all the necessary checks from decoders to encoders and I can surely say that there are not the cause of the error I am facing. This is the issue: I implement a TcpServer based using the ChannelTcp Listener example. Whenever a client connects and I want to send some packet to the connected client I got SocketError Connection Reset.
I guess I have to use the connected channel to send messages. I have read on MSDN some of the reasons of connection reset. With other implementation I did not get that error. So I suspect that I either doing something wrong with the library.

Please assist.

SqliteCommandBuilder should override InsertCommand for autoincrement

Insert command should do select last_insert_rowid() to get the autoinc key value. See below, also included code for paging, but have not tested it yet.

using System.Data;
using Griffin.Data.Mapper;
using Griffin.Data.Mapper.CommandBuilders;
using System.Linq;

namespace Griffin.Data.Sqlite
{
    /// <summary>
    /// Sqlite specific command builder.
    /// </summary>
    public class SqliteCommandBuilder : CommandBuilder
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="SqliteCommandBuilder"/> class.
        /// </summary>
        /// <param name="mapper">The mapper.</param>
        public SqliteCommandBuilder(ICrudEntityMapper mapper) : base(mapper)
        {
        }

        /// <summary>
        /// Generate an insert command, should end with a command that returns the insert identity.
        /// </summary>
        /// <param name="command">Command to add the query to</param>
        /// <param name="entity">Entity to store</param>
        /// <remarks>
        /// Last statement will return @@identity. 
        /// </remarks>
        public override void InsertCommand(IDbCommand command, object entity)
        {
            base.InsertCommand(command, entity);

            var gotAutoIncrement = Mapper.Properties.Any(x => x.Value.IsAutoIncrement && x.Value.IsPrimaryKey);
            if (!gotAutoIncrement)
                return;

            command.CommandText += ";select last_insert_rowid()";
        }

        /// <summary>
        /// Truncate all rows in a table
        /// </summary>
        /// <param name="command">Command that will be executed after this method call</param>
        /// <remarks>
        /// Will do a DELETE statement and reset the identity sequence generator.
        /// </remarks>
        public override void TruncateCommand(IDbCommand command)
        {
            command.CommandText = string.Format("DELETE FROM {0};DELETE FROM SQLITE_SEQUENCE WHERE name='{0}';",
                TableName);
        }

        /// <summary>
        /// Uses the SQLite - LIMIT [pageSize] OFFSET [pageNumber]
        /// LIMIT [no of rows] OFFSET [row num]
        /// </summary>
        /// <param name="command">command to modify</param>
        /// <param name="pageNumber">One based index</param>
        /// <param name="pageSize">Items per page.</param>
        public override void Paging(IDbCommand command, int pageNumber, int pageSize)
        {
            command.CommandText += string.Format(" LIMIT {1} OFFSET {0}",
                (pageNumber - 1) * pageSize, pageSize);
        }
    }
}

NRE in OnDecoderFailure

Object reference not set to an instance of an object
   at Griffin.Net.Channels.TcpChannel.Send (System.Object message) in <filename unknown>:line 0
   at Griffin.Net.Protocols.Http.HttpListener.OnDecoderFailure (ITcpChannel channel, System.Exception error) in <filename unknown>:line 0
   at Griffin.Net.Channels.TcpChannel.HandleDisconnect (SocketError socketError, System.Exception exception) in <filename unknown>:line 0
   at Griffin.Net.Channels.TcpChannel.ReadAsync () in <filename unknown>:line 0
   at Griffin.Net.Channels.TcpChannel.OnReadCompleted (System.Object sender, System.Net.Sockets.SocketAsyncEventArgs e) in <filename unknown>:line 0
   at System.Net.Sockets.SocketAsyncEventArgs.OnCompleted (System.Net.Sockets.SocketAsyncEventArgs e) in <filename unknown>:line 0
   at System.Net.Sockets.SocketAsyncEventArgs.ReceiveCallback (IAsyncResult ares) in <filename unknown>:line 0
   at System.Net.Sockets.SocketAsyncEventArgs.DispatcherCB (IAsyncResult ares) in <filename unknown>:line 0
   at System.Net.Sockets.SocketAsyncResult.<ExecuteWorkItem>m__1 (System.Object state) in <filename unknown>:line 0
   at (wrapper managed-to-native) System.Runtime.Remoting.Messaging.AsyncResult:Invoke (System.Runtime.Remoting.Messaging.AsyncResult)
   at System.Runtime.Remoting.Messaging.AsyncResult.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem () in <filename unknown>:line 0
   at System.Threading.ThreadPoolWorkQueue.Dispatch () in <filename unknown>:line 0
   at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback () in <filename unknown>:line 0

SemaphoreFullException

Using v2.1.1

System.Threading.SemaphoreFullException: Adding the specified count to the semaphore would cause it to exceed its maximum count.
   at System.Threading.SemaphoreSlim.Release(Int32 releaseCount)
   at Griffin.Net.Channels.TcpChannel.OnSendCompleted(Object sender, SocketAsyncEventArgs e)
   at System.Net.Sockets.SocketAsyncEventArgs.OnCompleted(SocketAsyncEventArgs e)
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Net.Sockets.SocketAsyncEventArgs.FinishOperationSuccess(SocketError socketError, Int32 bytesTransferred, SocketFlags flags)
   at System.Net.Sockets.SocketAsyncEventArgs.CompletionPortCallback(UInt32 errorCode, UInt32 numBytes, NativeOverlapped* nativeOverlapped)
   at System.Threading._IOCompletionCallback.PerformIOCompletionCallback(UInt32 errorCode, UInt32 numBytes, NativeOverlapped* pOVERLAP)

Logging question

I don't know if this is a feature or a bug, but please have a look at the code example below, which gives the following output:

Logger A says: ClassA is doing something.
Logger B says: ClassA is doing something.
Logger A says: ClassB is doing something.
Logger B says: ClassB is doing something.

while I would expect

Logger A says: ClassA is doing something.
Logger B says: ClassB is doing something.

This is because LogManager.GetLogger returns a CompositeLogger object containing both instances rather than the actual instance I registered. Is this intended? What would I have to change to get the desired logging behaviour?

Here's the code:

static void Main(string[] args)
{
    var loggerA = new SomeLogger(typeof(ClassA), "A");
    var loggerB = new SomeLogger(typeof(ClassB), "B");

    var provider = new LogProvider();

    provider.Add(loggerA);
    provider.Add(loggerB);

    LogManager.Provider = provider;

    var classA = new ClassA();
    var classB = new ClassB();

    classA.DoSomething();
    classB.DoSomething();

    Console.ReadLine();
}

class SomeLogger : BaseLogger
{
    string name;

    public SomeLogger(Type type, string name)
        : base(type)
    {
        this.name = name;
    }

    public override void Write(LogEntry entry)
    {
        Console.WriteLine("Logger {0} says: {1}", name, entry.Message);
    }
}

class ClassA
{
    ILogger _logger = LogManager.GetLogger<ClassA>();

    public void DoSomething()
    {
        _logger.Trace("ClassA is doing something.");
    }
}

class ClassB
{
    ILogger _logger = LogManager.GetLogger<ClassB>();

    public void DoSomething()
    {
        _logger.Trace("ClassB is doing something.");
    }
}

HttpMessageDecoder: use of message serializer

In the OnRequestLine method there are checks for _messageSerializer == null, but the message serializer isn't used at all. It's a bit confusing to get a HttpRequestBase in the one case, but a HttpRequest in the other.

Is there a reason for this?

Argument out of range exception in HttpMessageEncoder

Specified argument was out of the range of valid values.
Parameter name: count
  at System.Net.Sockets.SocketAsyncEventArgs.SetBufferInternal (System.Byte[] buffer, Int32 offset, Int32 count) <0x4116ec20 + 0x00113> in <filename unknown>:0 
  at System.Net.Sockets.SocketAsyncEventArgs.SetBuffer (System.Byte[] buffer, Int32 offset, Int32 count) <0x4116ebf0 + 0x0001b> in <filename unknown>:0 
  at Griffin.Net.Channels.SocketAsyncEventArgsWrapper.SetBuffer (System.Byte[] buffer, Int32 offset, Int32 count) <0x41203d90 + 0x00047> in <filename unknown>:0 
  at Griffin.Net.Protocols.Http.HttpMessageEncoder.Send (ISocketBuffer buffer) <0x41203620 + 0x00051> in <filename unknown>:0 
  at Griffin.Net.Channels.TcpChannel.OnSendCompleted (System.Object sender, System.Net.Sockets.SocketAsyncEventArgs e) <0x41204070 + 0x00082> in <filename unknown>:0 
  at System.Net.Sockets.SocketAsyncEventArgs.OnCompleted (System.Net.Sockets.SocketAsyncEventArgs e) <0x411fc710 + 0x0002e> in <filename unknown>:0 
  at System.Net.Sockets.SocketAsyncEventArgs.SendCallback (IAsyncResult ares) <0x41203f10 + 0x0014d> in <filename unknown>:0 
  at System.Net.Sockets.SocketAsyncEventArgs.DispatcherCB (IAsyncResult ares) <0x411fc2d0 + 0x000cf> in <filename unknown>:0 

TcpListener Proper way to stop TcpListener

Whenever I want to stop a TcpChannelListener I got the exception InvalidOperationException not listening you must call the start method before calling this method.

Pls what am doing wrong?

Usage of Serializer

Hello Jonas and Co,

I would like to know what will be the best way to use a serializer in the implementation of Decoder. The reason why I am asking this question is that all I have to do is to deserialize the data to receive

websockets

Hi Guys,
will the framework also support Websockets?
But congratulations. the performance is incredible.
best regards
Kai

Exceptiontype for cqs authorization

In Griffin.Cqs.Server AuthorizationModule.cs you throw AuthenticationException even whether you created an AuthorizationException in Griffin.Cqs/Authentication is there a reason for this purpose.

Problem with unhandled SemaphoreFullException

I use the HttpServer in a plugin than can be dynamically loaded and unloaded. When unloading the WebServer plugin, I get sometimes an unhandled SemaphoreFullException.

I had to modify the code in the following class:
Griffin.Net.Channels.TcpChannel in method OnSendCompleted()

catch (Exception ex)
{
try { _sendLock.Release(); }
catch(SemaphoreFullException)
{ }

OnChannelFailure(ex);
}

Thank you for adding this changes in the next nuget release :-)

thread safety problem?

Hello,

I have the web server sample code running. (Program2 from http://blog.gauffin.org/2014/05/griffin-framework-performant-networking-in-net/#more-4822)
I modified it to do SSL and print out the http method and the IP address. Here is the complete code:

    class MainClass
    {
        public static void Main (string[] args)
        {
            var certificate = new X509Certificate2("MyCert.p12", "password");
            var listener = new Griffin.Net.Protocols.Http.HttpListener();
            listener.ChannelFactory = new SecureTcpChannelFactory(new ServerSideSslStreamBuilder(certificate));
            listener.MessageReceived = OnMessage;
            //listener.BodyDecoder = new CompositeBodyDecoder();
            listener.Start(IPAddress.Any, 8443);
            Console.WriteLine ("Server running...");
            Console.ReadLine();
        }

        private static void OnMessage(ITcpChannel channel, object message)
        {
            var request = (HttpRequest)message;
            String FromIPAddress = ((IPEndPoint)request.RemoteEndPoint).Address.ToString ();
            Console.WriteLine ("Got " + request.HttpMethod + " request from " + FromIPAddress);

            var response = request.CreateResponse();
            if (request.Uri.AbsolutePath == "/favicon.ico")
            {
                Console.WriteLine ("Responding 404");
                response.StatusCode = 404;
                channel.Send(response);
                return;
            }

            var msg = Encoding.UTF8.GetBytes("Hello world");
            response.Body = new MemoryStream(msg);
            response.ContentType = "text/plain";
            channel.Send(response);
            if (request.HttpVersion == "HTTP/1.0")
                channel.Close();
        }
    }

I have two additional computers. On one (with IP .147) I am running a client that sends a POST message every 2 seconds. On the other one (with IP .55) I am running Apache Bench with:
ab -n 500 -r -f SSL3 https://185.185.185.136:8443/

The server output is this:

Got GET request from 185.185.185.55
Got POST request from 185.185.185.147
Got GET request from 185.185.185.55
Got GET request from 185.185.185.55
Got GET request from 185.185.185.55
Got GET request from 185.185.185.55
Got GET request from 185.185.185.55
Got GET request from 185.185.185.55
Got GET request from 185.185.185.55
Got GET request from 185.185.185.55
Got GET request from 185.185.185.55
Got GET request from 185.185.185.55
Got GET request from 185.185.185.55
Got POST request from 185.185.185.147
Got GET request from 185.185.185.55
Got GET request from 185.185.185.55
Got GET request from 185.185.185.55
Got GET request from 185.185.185.55
Got GET request from 185.185.185.55
Got GET request from 185.185.185.55
Got GET request from 185.185.185.55
Got POST request from 185.185.185.147
Got GET request from 185.185.185.55
Got GET request from 185.185.185.55
Got GET request from 185.185.185.55
Got GET request from 185.185.185.55
Got POST request from 185.185.185.147
Got GET request from 185.185.185.55
Got GET request from 185.185.185.55
Got GET request from 185.185.185.55
Got GET request from 185.185.185.55
Got GET request from 185.185.185.55
Got GET request from 185.185.185.55
Got GET request from 185.185.185.55
Got GET request from 185.185.185.55
Got GET request from 185.185.185.55
Got GET request from 185.185.185.55
Got GET request from 185.185.185.55
Got GET request from 185.185.185.55
Got GET request from 185.185.185.55
Got GET request from 185.185.185.55
Got POST request from 185.185.185.55
Got POST request from 185.185.185.55

Got GET request from 185.185.185.55
Got GET request from 185.185.185.55

The two lines in bold font make me really worried. How can that be? ApacheBench that runs on computer .55 does not send POST messages. On other tries I got the reverse, GET messages from .147. Could it be that something gets mixed up between threads?

Regards,
Gerhard.

Unhandled SemaphoreFullException in TcpChannel OnSendCompleted

Adding the specified count to the semaphore would cause it to exceed its maximum count.

at System.Threading.SemaphoreSlim.Release (Int32 releaseCount) in <filename unknown="">:line 0
at System.Threading.SemaphoreSlim.Release () in <filename unknown="">:line 0
at Griffin.Net.Channels.TcpChannel.OnSendCompleted (System.Object sender, System.Net.Sockets.SocketAsyncEventArgs e) in <filename unknown="">:line 0
at System.Net.Sockets.SocketAsyncEventArgs.OnCompleted (System.Net.Sockets.SocketAsyncEventArgs e) in <filename unknown="">:line 0
at System.Net.Sockets.SocketAsyncEventArgs.SendCallback (IAsyncResult ares) in <filename unknown="">:line 0
at System.Net.Sockets.SocketAsyncEventArgs.DispatcherCB (IAsyncResult ares) in <filename unknown="">:line 0
at System.Net.Sockets.SocketAsyncResult.<executeworkitem>m__1 (System.Object state) in <filename unknown="">:line 0
at (wrapper managed-to-native) System.Runtime.Remoting.Messaging.AsyncResult:Invoke (System.Runtime.Remoting.Messaging.AsyncResult)
at System.Runtime.Remoting.Messaging.AsyncResult.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem () in <filename unknown="">:line 0
at System.Threading.ThreadPoolWorkQueue.Dispatch () in <filename unknown="">:line 0
at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback () in <filename unknown="">:line 0

Data sample does not work....

wanted to see how well of a fit this framework would be to what I'm trying to do. After trying a bunch of things, I couldn't get the sample to compile.

It is referencing what I'm assuming the "old" framework. But even if I fix this, I couldn't get the sqlite portion to work. I even tried to grab the code and just add the project to my solution, but I still am getting errors like:

Error 11 'Griffin.Data.Mapper.EntityMapper<Sqlite.User>' does not contain a constructor that takes 1 arguments c:\code\griffin.framework\samples\data\sqlite\usermapper.cs 11 31 Sqlite

I could try and dig into what is causing this, and try to figure out how to make it work, but the point of this was to do a quick review / play around with the framework to see what it can do.

Really do like what you are doing with this (got me to register in github after years lurking). Will continue to keep an eye on it.

IndexOutOfRanceException in Http Header Parser

Reported by end user, cause as yet unknown. Stack trace follows:

System.IndexOutOfRangeException: Index was outside the bounds of the array.
      at Griffin.Net.Protocols.Http.Messages.HeaderParser.FirstLine (Char ch) <0x40d895e0 +="" 0x000da=""> in <filename unknown="">:0
      at Griffin.Net.Protocols.Http.Messages.HeaderParser.Parse (ISocketBuffer buffer, Int32 offset) <0x40d893c0 +="" 0x0003d=""> in <filename unknown="">:0
      at Griffin.Net.Protocols.Http.HttpMessageDecoder.ProcessReadBytes (ISocketBuffer buffer) <0x40d89120 +="" 0x0007f=""> in <filename unknown="">:0
      at Griffin.Net.Channels.TcpChannel.OnReadCompleted (System.Object sender, System.Net.Sockets.SocketAsyncEventArgs e) <0x40d88ec0 +="" 0x00166=""> in <filename unknown="">:0

Griffin.Data.Mapper question

i have 2 entity classes:

public class Document
{
    public int Id { get; set; }
    public DocumentCategory DocumentCategory { get; set; }
}

public class DocumentCategory
{
    public int Id { get; set; }
    public string Description { get; set; }
}

1 Mapper class

public class SimpleMapper : EntityMapper<document>
{
    // My questions is - What i need to write here to bind 
    // db column [CategoryId] to property [Document.DocumentCategory.Id]?
}

repository

public class DocumentRepository
{
    private AdoNetUnitOfWork _unitOfWork;

    public DocumentRepository(IUnitOfWork uow)
    {
        //hide
    }

    public async Task<document> GetAsync(int id)
    {
        using (var cmd = _unitOfWork.CreateCommand())
        {
            cmd.CommandText = "Document.GetDocumentById";
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.AddWithValue("id", id);

            return await cmd.FirstOrDefaultAsync<document>();      // exception goes here
        }
    }
}

stored precedure result

Id | CategoryId
1 | 1

Exception:

Griffin.Data.Mapper.MappingException:
CompanyName.DocFlow.DAL.Entities.Document: Failed to cast column value
to property value for
'CompanyName.DocFlow.DAL.Entities.Document.DocumentCategory'. --->
System.IndexOutOfRangeException: DocumentCategory

Http cookie access

It would be nice to have cookies available in IHttpRequest (or at least HttpRequestBase).

Spelling mistakes, etc.

I'm evaluating your program, and so far am fairly impressed.

Unfortunately (?), I have ReSharper and ReSpeller installed in my Visual Studio, and they flag all sorts of things that they don't like. And when it comes to spelling mistakes my obsessive-compulsive behavior takes over and I can't help fixing them.

I've submitted a pull request for the ones I've encountered so far that do not result in a breaking change when fixed.

In the Signals folder there is a consistent misspelling of "suppressed", and unfortunately some of them are public names, so fixing them will result in a breaking change for anyone using those parts of that facility. Let me know if you'd like me to submit a pull request for that.

Proxy Implementation

Hello I would like to know how best I can implement a Proxy using the network library.

Thank you.

Unsupported content type in HttpMessageDecoder

Griffin.Net.Protocols.Http.BadRequestException: Unsupported content-type: text/plain                                  
   at Griffin.Net.Protocols.Http.HttpMessageDecoder.TriggerMessageReceived (Griffin.Net.Protocols.Http.HttpMessage message) in <filename unknown>:line 0                                                                                   
   at Griffin.Net.Protocols.Http.HttpMessageDecoder.ProcessReadBytes (ISocketBuffer buffer) in <filename unknown>:line 0                                                                                                                    
   at Griffin.Net.Channels.TcpChannel.OnReadCompleted (System.Object sender, System.Net.Sockets.SocketAsyncEventArgs e) in <filename unknown>:line 0      

ReadMe for Data Extensions 'project' confusing

Near the bottom of the ReadMe, you have;

"To make it work you need to configure the UnitOfWorkFactory:

public static void Main(string[] argv)
{
    UnitOfWorkFactory.SetFactoryMethod(CreateUow);
}

"

The confusing part is that I can't see the "CreateUow" method anywhere else in that readme, so I'm not 100% sure what that's supposed to look like. Clarification appreciated. :)

If it's...

public IUnitOfWork Create()
{ ... }

...I believe it would be helpful to rename public IUnitOfWork Create() to public IUnitOfWork CreateUow() so as to make it REALLY obvious. I hope I'm not being to pedantic here, but I hate to assume with this kind of information.

ChannelTcpListener MessageReceived not triggering

I added the project via NuGet and copied and pasted the "Server" example as shown in the project website.

When I try to connect using a TCP Client for Android I receive the log related to the connection event but when I send text I do not get anything at all. No exceptions, the MessageReceived callback does not execute.

I tried setting the encoder/decoder as StringDecoder, StringEncoder (since text is the only thing I need) and nothing happens.

I downloaded the project and added as a normal reference and trying to debug the ProcessReadBytes method from StringDecoder I noticed that it never goes beyond this:

if (_bytesLeftForCurrentMsg != 0)
continue;

I also noticed the _bytesLeftForCurrentMsg variable has 1969648996 as value which seems weird since I sent a little message...

Is there a known issue about this? What am I be doing wrong?

Streaming question

I work on IoT project (Windows 10 IoT Core \ UWP) and trying to build MJpeg live video-streaming service.

After I went through your code it is still looks quite tricky to me.
Basically I just need the way to get down to tcp connection on incoming request and together with response headers start sending mjpeg frames.

Here is an example of simple mjpeg streaming using Web.API which I'm trying to implement using your framework.

What is your opinion on this? Could you please point me where to start? Do I need to implement own listener or I can reuse HttpListener, but with a new encoder?

Null Exception (Thread Race Case?)

In HttpMessageEncoder.cs:Line 144, I've noticed it throwing a really really weird error.

_message.Body.Dispose( ); was throwing the error. Apparently _message was null?!?! Even after your if statement... Threading is beyond me.

I fixed it by locking the whole class, but I don't know if that is the best way to do it.

public void Clear()
{
    lock ( this )
    {
        if ( _message != null && _message.Body != null )
            _message.Body.Dispose( );

        _bytesToSend = 0;
        _message = null;
        _isHeaderSent = false;
        _stream.SetLength( 0 );
    }
}

Either way, sweet project for sure! Thanks

Implement a Client using ChannelTcpClient

I am able to implement a decoder and an encoder and use them as follow:
_channelTcpClient = new ChannelTcpClient(MessageEncoder, MessageDecoder);

However the message is well decoded but I cannot have access to it. What am I doing wrong?

How I can loop for get more messages?

In your example:

[..]
if (_bytesLeft == 0)
{
_stream.Position = 0;
var item = _serializer.Deserialize(new StreamReader(_stream), typeof (object));
MessageReceived(item);
Clear();

        //TODO: Recursive call to read any more messages
    }

[..]

How I can loop for read more messages?

thank you!

Access of disposed object in TcpChannel.OnSendCompleted

Cannot access a disposed object.
Object name: 'System.Net.Sockets.Socket'.
   at System.Net.Sockets.Socket.SendAsync(SocketAsyncEventArgs e)
   at Griffin.Net.Channels.TcpChannel.OnSendCompleted(Object sender, SocketAsyncEventArgs e)
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Net.Sockets.SocketAsyncEventArgs.FinishOperationSuccess(SocketError socketError, Int32 bytesTransferred, SocketFlags flags)
   at System.Net.Sockets.SocketAsyncEventArgs.CompletionPortCallback(UInt32 errorCode, UInt32 numBytes, NativeOverlapped* nativeOverlapped)
   at System.Threading._IOCompletionCallback.PerformIOCompletionCallback(UInt32 errorCode, UInt32 numBytes, NativeOverlapped* pOVERLAP)

NRE in HttpMessageDecoder OnHeader

I'm getting reports of a NRE in the above method, stack trace from an end-user follows:

System.NullReferenceException: Object reference not set to an instance of an object
  at Griffin.Net.Protocols.Http.HttpMessageDecoder.OnHeader (System.String name, System.String value) <0x413c9200 + 0x00026> in <filename unknown>:0 
  at Griffin.Net.Protocols.Http.Messages.HeaderParser.Value_CompletedOrMultiLine (Char ch) <0x413c9040 + 0x000f8> in <filename unknown>:0 
  at Griffin.Net.Protocols.Http.Messages.HeaderParser.Parse (ISocketBuffer buffer, Int32 offset) <0x413c70e0 + 0x0003d> in <filename unknown>:0 
  at Griffin.Net.Protocols.Http.HttpMessageDecoder.ProcessReadBytes (ISocketBuffer buffer) <0x413c6e40 + 0x0007f> in <filename unknown>:0 
  at Griffin.Net.Channels.TcpChannel.OnReadCompleted (System.Object sender, System.Net.Sockets.SocketAsyncEventArgs e) <0x413c6be0 + 0x00166> in <filename unknown>:0 

I'm having a hard time reproducing the issue locally, but it seems that there may be a case where _message is being set to NULL before the request completes.

there is no OnServerMessageReceived event .

hi.
i used your library in vb.net.
but this line error
AddHandler server.OnServerMessageReceived, AddressOf OnServerMessageReceived

but others are ok
AddHandler server.ClientConnected, AddressOf clientconnected
AddHandler server.ClientDisconnected, AddressOf ClientDisconnected

there is no OnServerMessageReceived handler in the library.
please fix it.
thanks

samples\Networking\CustomProtocol\DemoTest using old version of Framework?

I'm still playing around with your program, trying to understand it, which is a challenge for me since I've never used async / await before. In order to make it easier to single-step from the DemoTest program into the Framework.Core module I tried changing the .csproj file to reference the version of Framework.Core that I'm building. But then I got an error saying that "ChannelTcpClient" is invalid because ChannelTcpClient is not generic. Is this due to the DemoTest project using nuget to load an old version of Framework? (I've changed .csproj back again.)

Anyway, as I play around with your program I'm making some cosmetic changes, for example adding a few comments and correcting the English in comments (I'm a native English speaker). This is my way of learning a new program. I'll submit another pull request later. If you'd prefer not to have the bother of such trivial pull requests let me know.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.