2014. 6. 2. 06:42

Linux SSH Session Timeout Setting

Our project faced a very weird problem that SSH.Net cannot get the exit event after 10 minutes. Though the command was finished, SSH.Net was waiting for its completion.


The reason was caused by the time-out of the ssh session. To increase this, set it as below.


sudo vi /etc/ssh/sshd_config


# 300 secons

ClientAliveInterval 300

# 300 * (12) MAX 1 HOUR

ClientAliveCountMax 12


$ sudo service ssh restart


After this, it worked well.

2014. 5. 24. 08:36

PollingDuplex multiple mode timeouts demystified

Source: http://blogs.msdn.com/b/silverlightws/archive/2010/07/16/pollingduplex-multiple-mode-timeouts-demystified.aspx


Written by   



The new MultipleMessagesPerPoll mode added to PollingDuplex in Silverlight 4, comes with some new timeouts , so I thought it would be useful to post a detailed description of how those work. Unfortunately this is not currently covered by our documentation, which is something we are looking to address in upcoming documentation refreshes.

This is a fairly advanced topic, and the default settings should work well for most customers, so only modify these if you are encountering an issue, and you are fairly confident a timeout is causing the problem. The information below applies only to the new multiple messages mode, which is activated by settingduplexMode="MultipleMessagesPerPoll" on the PollingDuplex binding or binding element.

One important thing in the text below is to differentiate between infrastructure messages (such as polls in this case) and application messages. Infrastructure messages such as polls (and poll responses) are not initiated by or surfaced to the user – they are just an implementation detail of the protocol. Application messages are messages that actually originated in the user code. They can be separated into client-to-server messages (“requests coming from client”) or server-to-client messages (“server responses to requests coming from client” and “requests coming from server”). There is no “client responses coming from server” because of the way polling works. I will try to stick to this terminology in the text below.

Most of the new timeouts live on the server. All class and member names refer to the server-side System.ServiceModel.PollingDuplex.dll that ships in the “Server” folder of the Silverlight SDK. Take a look at the following diagram for a visual explanation:




The diagram shows an incoming poll and the chunked response being returned containing application messages. The first server-to-client application message is greater than 16/32KB (16 for self-hosted PollingDuplex services, 32KB for IIS-hosted), so the chunked response is flushed and the message should arrive immediately at the client. The then client sends a smaller application messages, but the total size does not reach 16/32KB, so the chunked response is not flushed. To prevent the message from getting stuck, the chunked response will be flushed and closed when the MaxOutputDelay timer expires, and the message will then be delivered to the client. Then the client sends two application messages coming in from the client and the timeouts associated with those.

Here is a more detailed description of each timeout.

ServerPollTimeout

  • Set it here
    • System.ServiceModel.PollingDuplexHttpBinding.ServerPollTimeout
    • System.ServiceModel.Channels.PollingDuplexBindingElement.ServerPollTimeout
  • Definition: Time the server holds the poll request prior to sending an empty poll response to the client. After the first outgoing server-to-client application message (either server response to request coming from client or request coming from the server) gets sent, this timer stops being used, andMaxOutputDelay kicks in. Bound to the client dispatcher (HTTP request / response)
  • Default: 15 s

MaxOutputDelay

  • Set it here
    • System.ServiceModel.PollingDuplexHttpBinding.MaxOutputDelay
    • System.ServiceModel.Channels.PollingDuplexBindingElement.MaxOutputDelay
  • Definition: Time between the last outgoing server-to-client application message and the HTTP response being closed; it’s reset with each new outgoing message being dequeued. Closing the response ensures that all messages are flushed and no message will take longer than MaxOutputDelay to be delivered to the client. Bound to the client dispatcher.
  • Default: 200 ms

PollHeartbeatTimeout

  • Not settable – this is an internal property
  • Definition: Timer which is started when a poll response is sent to the client, and stopped when the next poll for that dispatcher is received. Bound to the client dispatcher. If the timeout is reached, all the channels bound to the dispatcher are faulted. This is how we determine if a client “is still there”.
  • Value: 4 * ServerPollTimeout + 30 s (after polling has started), 2 * ServerPollTimeout + 15 s (if server has not received the first poll from the client)

InactivityTimeout

  • Set it here
    • System.ServiceModel.PollingDuplexHttpBinding.InactivityTimeout
    • System.ServiceModel.Channels.PollingDuplexBindingElement.InactivityTimeout
  • Definition: Timer which is reset when an application messages is received by the channel. If the timeout is reached, the channel is faulted. Bound to the client session. Note that this not affected by polls, contrary to the way this same timeout behaves with infrastructure messages on other bindings (as described here). So effectively this is the same as ReceiveTimeout.
  • Default: 10 min

ReceiveTimeout

  • Set it here
    • System.ServiceModel.Channels.Binding.ReceiveTimeout
  • Definition: Timer which is reset when the ServiceModel layer pumps an application message from a PollingDuplex channel. If the timeout is reached, the channel is aborted. Infrastructure messages such as polls don’t affect this timeout. Bound to the client session (channel).
  • Default: 10 min

 

On the client side, we also have some timeouts that may be of interest. All class and member names below refer to the client-side System.ServiceModel.PollingDuplex.dll that ships in the “Client” folder of the Silverlight SDK.

ClientPollTimeout

InactivityTimeout

Hope this is useful.

2014. 5. 24. 07:30

WCF Configuration Schema (web.config)


The following link shows the detailed information about wcf web.config configuration. 


http://msdn.microsoft.com/en-us/library/ms731734(v=vs.110).aspx






The tip to search for msdn site, use "site:" option on Google.


site:http://msdn.microsoft.com/en-us wcf "<bind>" 



Additionally silverlight configuration schema site is as below:


http://msdn.microsoft.com/ko-kr/library/dd547083(v=vs.95).aspx

2014. 5. 22. 07:03

List All Linux Commands

Using compgen can list all available commands in Linux.

 

 

compgen -c 

 

Using grep command together, you can extract some command to find.

 

compgen -c | grep mysql 

 

 

To list all the bash shell aliases available,

 

compgen -a 

 

Reference: http://www.cyberciti.biz/open-source/command-line-hacks/compgen-linux-command/

 

2014. 5. 20. 05:56

WCF Tracing and Message Logging

Really I did ridiculous thing. 


Our system showed "Server too busy" exception so I wanted to trace the log messages of the WCF services. I followed lots of instructions for that. 



And the critical thing was as below:


  <sharedListeners>
    <add name="xml"
         type="System.Diagnostics.XmlWriterTraceListener"
               initializeData="C:\logs\Traces.svclog" />
  </sharedListeners>


After restarting our service, I refreshed the windows explorer to check if the log file was created but it didn't. 


The reason was very simple. The log file couldn't be created if the destination folder does not exist. So only after creating the 'c:\logs' folder, my concern was removed.



MSDN offers the recommended settings for tracing and message logging

(http://msdn.microsoft.com/en-us/library/aa702726(v=vs.110).aspx)



  • Recommnded Settings for a Production Environment

<configuration>
 <system.diagnostics>
  <sources>
    <source name="System.ServiceModel"
            switchValue="Warning"
            propagateActivity="true" >
      <listeners>
        <add name="xml"/>
      </listeners>
    </source>
    <source name="myUserTraceSource"
            switchValue="Warning, ActivityTracing">
      <listeners>
        <add name="xml"/>
      </listeners>
    </source>
  </sources>
  <sharedListeners>
    <add name="xml"
         type="System.Diagnostics.XmlWriterTraceListener"
               initializeData="C:\logs\Traces.svclog" />
  </sharedListeners>
 </system.diagnostics>

<system.serviceModel>
  <diagnostics wmiProviderEnabled="true">
  </diagnostics>
 </system.serviceModel>
</configuration>

  • Recommended Settings for Deployment or Debugging
configuration>
 <system.diagnostics>
  <sources>
    <source name="System.ServiceModel"
            switchValue="Information, ActivityTracing"
            propagateActivity="true" >
      <listeners>
        <add name="xml"/>
      </listeners>
    </source>
    <source name="System.ServiceModel.MessageLogging">
      <listeners>
        <add name="xml"/>
      </listeners>
    </source>
    <source name="myUserTraceSource"
            switchValue="Information, ActivityTracing">
      <listeners>
        <add name="xml"/>
      </listeners>
    </source>
  </sources>
  <sharedListeners>
    <add name="xml"
         type="System.Diagnostics.XmlWriterTraceListener"
               initializeData="C:\logs\Traces.svclog" />
  </sharedListeners>
 </system.diagnostics>

 <system.serviceModel>
  <diagnostics wmiProviderEnabled="true">
      <messageLogging 
           logEntireMessage="true" 
           logMalformedMessages="true"
           logMessagesAtServiceLevel="true" 
           logMessagesAtTransportLevel="true"
           maxMessagesToLog="3000" 
       />
  </diagnostics>
 </system.serviceModel>
</configuration>

To see the logs, use the service trace viewer tool!
(C:\Program Files\Microsoft SDKs\Windows\v6.0\Bin\SvcTraceViewer.exe)

(http://msdn.microsoft.com/en-us/library/ms732023(v=vs.110).aspx)



2014. 4. 29. 02:51

Dealing with those pesky WCF CommunicationException “NotFound” errors in Silverlight

The following links are very helpful to figure out the problem that shows "NotFound" errors in Silverlight.



Dealing with those pesky WCF CommunicationException “NotFound” errors in Silverlight


http://blogs.msdn.com/b/silverlightws/archive/2010/04/15/dealing-with-those-pesky-wcf-communicationexception-notfound-errors-in-silverlight.aspx


Creating and Handling Faults in Silverlight

(http://msdn.microsoft.com/en-us/library/ee844556(v=VS.95).aspx)


Configuring WCF SOAP Faults for Use with Silverlight Clients

Receiving SOAP faults is not supported in the default configuration, due to Web browser limitations. When the service does send a fault, an exception is thrown on the client, but it does not specify any information about the fault that has occurred. However, there are two ways to enable SOAP fault consumption:

  • Modify the HTTP status code: You can modify your service to return SOAP faults with an HTTP status code of 200, Silverlight 4 so that faults will be processed successfully. How to do this is outlined below. Note that this will make the service non-compliant with the SOAP protocol, because SOAP requires a response code in the 400 or 500 range for faults. If the service is a WCF service, you can create an endpoint behavior that plugs in a message inspector that changes the status code to 200. Then you can create an endpoint specifically for Silverlight consumption, and apply the behavior there. Your other endpoints will still remain SOAP-compliant. 

  • Use the alternative client HTTP stack: You can register an alternative HTTP stack by using the RegisterPrefix method. See below for an outline of how to do this. Silverlight 4 provides the option of using a client HTTP stack which, unlike the default browser HTTP stack, allows you to process SOAP-compliant fault messages. However, a potential problem of switching to the alternative HTTP stack is that information stored by the browser (such as authentication cookies) will no longer be available to Silverlight, and thus certain scenarios involving secure services might stop working, or require additional code to work. For more information, see HttpCookieContainerBindingElement.


2014. 4. 29. 02:39

upload and download over 30 MB file between silverlight and wcf service

Recently My project members and I are suffering from the problem that cannot upload and download over 30 MB file between silverlight and wcf service.


I googled lots of things and applied the suggestions but anything did not resolve our issue.


With this trouble remained I cannot sleep well so I'm writing this article now.


I searched more webs to find any hint to help us. Following sites can be helpful but the result will be known tomorrow.


http://ajaxuploader.com/large-file-upload-iis-debug.htm


This site suggests very good guide lines as below: 


1. Required

IIS7 - maxAllowedContentLength

IIS6 - maxRequestLength


2. Microsoft URL Scan

C:\WINDOWS\system32\inetsrv\urlscan\UrlScan.ini

MaxAllowedContentLength


3. File upload debug file


debug-upload.zip



http://ajaxuploader.com/large-file-upload-iis-asp-net.htm


This sites shows the required configuration for IIS7


1. Modify the maxAllowedContentLength setting in the web.config


<system.webServer>
  <security>
    <requestFiltering>
      <requestLimits maxAllowedContentLength="2147483648" />
    </requestFiltering>
  </security>

</system.webServer> 


=> 2147483648 - 2 GB in size

2. Edit the request filtering feature settings and the request limits using IIS manager

  • Open IIS Manager.
  • Select the website that you want to configure.
  • Make sure you are in Features View per the button at the bottom of the manager.
  • Select Requests Filtering and open it by double-clicking the icon. The Request Filtering pane displays.
  • From the Actions pane on the right hand side of the screen click Edit Feature Settings... link. The Edit Request Filtering Settings window displays.
  • In the Request Limits section, enter the appropriate Maximum allowed content length (Bytes) and then click the OK button.
  • Restart IIS.


3. Manually edit the ApplicationHost.config file



  • Click Start. In the Start Search box, type Notepad. Right-click Notepad, and then click Run as administrator.
  • On the File menu, click Open. In the File name box, type %windir%\system32\inetsrv\config\applicationhost.config, and then click Open.
  • In the ApplicationHost.config file, locate the <requestLimits> node.
  • Remove the maxAllowedContentLength property. Or, add a value that matches the size of the Content-Length header that the client sends as part of the request. By default, the value of the maxAllowedContentLength property is 30000000. 

    For example, modify the following configuration data inside the <requestFiltering> section.

    <requestLimits maxAllowedContentLength ="<length>" />
  • Save the ApplicationHost.config file.


Finally to resolve this, we developed upload/download feature with new way: duplex communication on download and upload partitioning.


But this information is worth keeping in mind.

2014. 1. 7. 02:24

How to: Build a Duplex Service for a Silverlight Client


Do not forget to call Close (CloseAsync in case of Silverlight) of Proxy Service Client!



sl4_wcf_nettcp_duplex_article.zip



References:




2014. 1. 6. 06:43

Forward Engineer SQL script using MySQL Workbench

MySQL Workbench had nice feature to make SQL script to create a schema from existing database but it was not easy to find where it is.


1. Start MySQL Workbench


2. Select "Create EER Model From Existing Database" in the 'Data Modeling' section.

  (If you already have existing EER model, select it)





 * Enter required information and select Schema to reverse engineer


3. If EER Diagram is opened without any problem, Select "File > Export > Forward Engineer SQL CREATE Script..." like the following :





4. Select any option as you wish from the dialog and proceed the steps until the finish button is shown like the following. 





5. It's the SQL script we want.




2014. 1. 6. 06:09

Create MySQL ERD using ERWin

Visit the following site to get more detail:


http://mkyojung.wordpress.com/2012/09/21/erwin%EC%97%90%EC%84%9C-mysql-erd-%EC%83%9D%EC%84%B1reverse-engineering/